⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hfilefactory_ring.cpp

📁 Resource editor base speadrum Chinese mobile
💻 CPP
字号:
// HFileFactory_Ring.cpp: implementation of the CHFileFactory class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "resourceeditor.h"
#include "HFileFactory.h"
#include "DirFileInfo.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

BOOL CHFileFactory::GenerateRingH( LPCTSTR pszFileName , CString bin_name)
{
    _ASSERTE( pszFileName != NULL && m_pMMIRes != NULL );

    if( !IsCoverFile(pszFileName) )
        return  FALSE;
	
    //buffer for unicode to mbcs
	char *pszBuf = new char[1024*100];
	int nUnicodeSize = 0; // by 16-bit

    CFile file;
    try{
        if( !file.Open(pszFileName, CFile::modeCreate | CFile::modeWrite) )
        {
            return FALSE;
        }
		
		_TCHAR szTitle[] = 
			_T("/*****************************************************************************\r\n")
			_T("** File Name:      xxx_mmi_ring.h                                            *\r\n")
			_T("** Author:                                                                   *\r\n")
			_T("** Date:           05/2006                                                   *\r\n")
			_T("** Copyright:      2006 Spreadtrum, Incoporated. All Rights Reserved.        *\r\n")
			_T("** Description:    This file is used to describe call log                    *\r\n")
			_T("******************************************************************************\r\n")
			_T("**                         Important Edit History                            *\r\n")
			_T("** --------------------------------------------------------------------------*\r\n")
			_T("** Create by Spreadtrum Resource Editor tool                                 *\r\n")
			_T("******************************************************************************/\r\n\r\n");

		_TCHAR szBegin[] = 
			_T("#ifndef _MMI_RING_H__\r\n")
			_T("#define _MMI_RING_H__\r\n\r\n")
			_T("#include \"sci_types.h\"\r\n")
			_T("#include \"dal_audio.h\"\r\n")
			_T("#include \"mmi_module.h\"\r\n\r\n")
			_T("#ifdef __cplusplus\r\n")
			_T("extern   \"C\" {\r\n")
			_T("#endif\r\n\r\n")
			/*
			"// Define Ring Type\r\n"
			"typedef enum _AUD_RING_TYPE_E\r\n"
			"{\r\n"
			"\tAUD_MIDI_RING,          // File format: General Midi file format \r\n"
			"\tAUD_SINGLE_TONE_RING,   // File format(in BigEndian):\r\n"
			"\tAUD_DUAL_TONE_RING,     // File format(in BigEndian):\r\n"
			"\tAUD_TRIPLE_TONE_RING,   // File format(in BigEndian):\r\n"
			"\tAUD_SMAF_RING,          // File format: Defined by Yamaha\r\n"
			"\tAUD_WAVE_RING,          // File format: \r\n"
			"\tAUD_RING_TYPE_MAX       // Reserved, user can't use it.\r\n"
			"} AUD_RING_TYPE_E;\r\n\r\n"
			*/
			_T("typedef struct _AUD_RING_DATA_INFO_T\r\n")
			_T("{\r\n")
			_T("\tAUD_RING_TYPE_E   type;\r\n")
			_T("\tuint32            data_len;\r\n")
			_T("\tuint8            *data_ptr;\r\n")
			_T("} MMIAUD_RING_DATA_INFO_T, * PMMIAUD_RING_DATA_INFO_T;\r\n\r\n\r\n")
			_T("typedef enum _MMI_RING_ID_E\r\n")
			_T("{\r\n");

    

		_TCHAR szEnd[] = 
			_T("} MMI_RING_ID_E;\r\n\r\n")
			//@hongliang 2007-3-26
			//_T("extern BOOLEAN MMI_GetRingInfo(uint16 label, MMIAUD_RING_DATA_INFO_T * pRingInfo);\r\n\r\n")
			_T("#ifdef __cplusplus\r\n")
			_T("}\r\n")
			_T("#endif\r\n\r\n")
			_T("#endif // _MMI_RING_H__");


        //write file head		
		nUnicodeSize = _tcslen(szTitle);
		WideCharToMultiByte( CP_ACP, 0, szTitle, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
		
		nUnicodeSize = _tcslen(szBegin);
		WideCharToMultiByte( CP_ACP, 0, szBegin, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
		
		//write module name in enum start
	    LPCTSTR pFind = _tcsrchr(bin_name, _T('\\'));
		if( NULL == pFind )
			pFind = bin_name;
		else
			pFind++;

    	CString moduleName = pFind;
		CString tempstr;
		CString module_header;
		CString strLine;
		int nLeft = moduleName.ReverseFind(_T('.'));
		if( nLeft > 0 )
		module_header=moduleName = moduleName.Left(nLeft);
		moduleName.Insert(0,_T("MMI_MODULE_"));
    	moduleName.MakeUpper();
		tempstr.Format(_T("%s"),moduleName);
		module_header.MakeUpper();
		
    	strLine.Format(_T("\t%s_%s = %s << %d,\r\n"),module_header, _T("RING_NULL"),tempstr,16);
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));

        //write module name end       
        CDirFileInfo * pInfo = g_theApp.m_pRingInfo;
        _ASSERTE( pInfo != NULL );
    
        CStringArray arrID;
        pInfo->CalcAllLeafID(arrID);
    
        int nSize = arrID.GetSize();    
        
        for( int i = 0; i < nSize; ++i )
        {      
            strLine.Format(_T("\t%s,\r\n"), arrID[i]);
            nUnicodeSize = strLine.GetLength();
			WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
			file.Write(pszBuf, strlen(pszBuf));
        }

        strLine = _T("\tRING_MAX_ID\r\n");
		nUnicodeSize = strLine.GetLength();
		WideCharToMultiByte( CP_ACP, 0, strLine, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));
			
		nUnicodeSize = _tcslen(szEnd);
		WideCharToMultiByte( CP_ACP, 0, szEnd, -1, pszBuf, nUnicodeSize*2, NULL, NULL );
		file.Write(pszBuf, strlen(pszBuf));

        file.Close();
		delete[] pszBuf;
    }
    catch(CFileException * pfe)
    {
        pfe->ReportError();
        pfe->Delete();
		delete[] pszBuf;
        return FALSE;
    }

    return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -