qtecomplugins/xqecom/main.cpp
changeset 4 90517678cc4f
parent 1 2b40d63a9c3d
equal deleted inserted replaced
1:2b40d63a9c3d 4:90517678cc4f
    25 #include <QIODevice>
    25 #include <QIODevice>
    26 #include <QTextStream>
    26 #include <QTextStream>
    27 #include <QDateTime>
    27 #include <QDateTime>
    28 #include <QFileInfo>
    28 #include <QFileInfo>
    29 
    29 
    30 #define PLUGIN_WINSCW_DEF_FILE_ACTUAL "plugin_common_winscw.def"
       
    31 #define PLUGIN_EABI_DEF_FILE_ACTUAL "plugin_common_arm.def"
       
    32 #define IMPLEMENTATION_UID_LIT "KQtEcomPluginImplementationUid"
    30 #define IMPLEMENTATION_UID_LIT "KQtEcomPluginImplementationUid"
    33 
       
    34 void runDefFileGenerator()
       
    35 {	
       
    36 	QFile ft(QLatin1String(PLUGIN_WINSCW_DEF_FILE_ACTUAL));
       
    37 	if(!ft.exists()){
       
    38 		if(ft.open(QIODevice::WriteOnly)){
       
    39 			QTextStream t(&ft);
       
    40 			t << "EXPORTS" << endl;
       
    41 			t << "\t?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)" << endl;
       
    42 			t << endl;
       
    43 			printf("Generated: ");
       
    44 			printf((QFileInfo(ft).absoluteFilePath()).toLocal8Bit().data() );
       
    45 			printf("\n");
       
    46 	    }else{
       
    47 			printf("Not generated: ");
       
    48 			printf((QFileInfo(ft).absoluteFilePath()).toLocal8Bit().data() );
       
    49 			printf(" - Error %d\n",ft.error());
       
    50 		}
       
    51 	}else{
       
    52 		printf("Not generated: ");
       
    53 		printf((QFileInfo(ft).absoluteFilePath()).toLocal8Bit().data() );
       
    54 		printf(" - File exists\n");					
       
    55 	}
       
    56 	
       
    57 	QFile ftArm(QLatin1String(PLUGIN_EABI_DEF_FILE_ACTUAL));
       
    58 	if(!ftArm.exists()){
       
    59 		if(ftArm.open(QIODevice::WriteOnly)) {
       
    60 			QTextStream t(&ftArm);
       
    61 			t << "EXPORTS" << endl;
       
    62 			t << "\t_Z24ImplementationGroupProxyRi @ 1  NONAME" << endl;
       
    63 			t << endl;
       
    64 			printf("Generated: ");
       
    65 			printf((QFileInfo(ftArm).absoluteFilePath()).toLocal8Bit().data() );
       
    66 			printf("\n");
       
    67 	    }else{
       
    68 			printf("Not generated: ");
       
    69 			printf((QFileInfo(ftArm).absoluteFilePath()).toLocal8Bit().data() );
       
    70 			printf(" - Error %d\n",ftArm.error());
       
    71 		}
       
    72 	}else{
       
    73 		printf("Not generated: ");
       
    74 		printf((QFileInfo(ftArm).absoluteFilePath()).toLocal8Bit().data() );
       
    75 		printf(" - File exists\n");					
       
    76 	}
       
    77 
       
    78 }
       
    79 
    31 
    80 void runRSSFileGenerator(QStringList params)
    32 void runRSSFileGenerator(QStringList params)
    81 {
    33 {
    82     QString appName = params[1];
    34     QString appName = params[1];
    83 	QString uid3 = params[2];
    35 	QString uid3 = params[2];
    84 	QString interfacename = params[3];
    36 	QString interfacename = params[3];
    85 	QString configuration = params[4];
    37 	QString configuration = params[4];
    86 	QString configurationFile = params[5];
    38 	QString configurationFile = params[5];
    87 	
    39 	
    88 	QString rssFilename = appName;
    40 	QString rssFilename = appName;
    89     rssFilename.append(".rss");
    41     rssFilename.append(QString::fromLatin1(".rss"));
    90 
    42 
    91     QFile ft(rssFilename);
    43     QFile ft(rssFilename);
    92 	if(!ft.exists()){
    44 	if(!ft.exists()){
    93 		if(ft.open(QIODevice::WriteOnly)) {
    45 		if(ft.open(QIODevice::WriteOnly)) {
    94 			QTextStream t(&ft);
    46 			QTextStream t(&ft);
   103 			t << "//" << endl;
    55 			t << "//" << endl;
   104 			t << "// ==============================================================================" << "\n" << endl;
    56 			t << "// ==============================================================================" << "\n" << endl;
   105 			t << endl;
    57 			t << endl;
   106 
    58 
   107 	        if (interfacename.isEmpty()) {
    59 	        if (interfacename.isEmpty()) {
   108 	            interfacename = QString(appName).append(".dll");
    60 	            interfacename = QString(appName).append(QString::fromLatin1(".dll"));
   109 	        }
    61 	        }
   110 			
    62 			
   111 	        QTextStream configStream;
    63 	        QTextStream configStream;
   112 	        QFile cfgFile;
    64 	        QFile cfgFile;
   113 			
    65 			
   125 	        } else {
    77 	        } else {
   126 				configStream.setString( &configuration, QIODevice::ReadOnly );
    78 				configStream.setString( &configuration, QIODevice::ReadOnly );
   127 	        }
    79 	        }
   128 
    80 
   129 			
    81 			
   130 	        t << "#include <RegistryInfoV2.rh>" << endl << endl;
    82 	        t << "#include <registryinfov2.rh>" << endl << endl;
   131 	        t << "#include <xqtecom.hrh>" << endl << endl;
    83 	        t << "#include <xqtecom.hrh>" << endl << endl;
   132 	        t << "#include <ecomstub_" << uid3 << ".hrh>" << endl << endl;
    84 	        t << "#include <ecomstub_" << uid3 << ".hrh>" << endl << endl;
   133 	        t << "RESOURCE REGISTRY_INFO theInfo" << endl << "{" << endl;
    85 	        t << "RESOURCE REGISTRY_INFO theInfo" << endl << "{" << endl;
   134 	        t << "resource_format_version = RESOURCE_FORMAT_VERSION_2;" << endl;
    86 	        t << "resource_format_version = RESOURCE_FORMAT_VERSION_2;" << endl;
   135 	        t << "dll_uid = " << uid3 << ";" << endl;
    87 	        t << "dll_uid = " << uid3 << ";" << endl;
   137 	        t << "\t\tinterface_uid = KQtEcomPluginInterfaceUID;" << endl;
    89 	        t << "\t\tinterface_uid = KQtEcomPluginInterfaceUID;" << endl;
   138 	        t << "\t\timplementations =" << endl << "\t\t\t{" << endl;
    90 	        t << "\t\timplementations =" << endl << "\t\t\t{" << endl;
   139 	        t << "\t\t\tIMPLEMENTATION_INFO" << endl << "\t\t\t\t{" << endl;
    91 	        t << "\t\t\tIMPLEMENTATION_INFO" << endl << "\t\t\t\t{" << endl;
   140 	        t << "\t\t\t\timplementation_uid = " << IMPLEMENTATION_UID_LIT << ";" << endl;
    92 	        t << "\t\t\t\timplementation_uid = " << IMPLEMENTATION_UID_LIT << ";" << endl;
   141 	        t << "\t\t\t\tversion_no = 1;" << endl;
    93 	        t << "\t\t\t\tversion_no = 1;" << endl;
   142 	        t << "\t\t\t\tdisplay_name = \"" << appName+QString(".dll") << "\";" << endl;
    94 	        t << "\t\t\t\tdisplay_name = \"" << appName+QString(QString::fromLatin1(".dll")) << "\";" << endl;
   143 	        t << "\t\t\t\t// SERVICE.INTERFACE_NAME" << endl;
    95 	        t << "\t\t\t\t// SERVICE.INTERFACE_NAME" << endl;
   144 	        t << "\t\t\t\tdefault_data = \"" << interfacename << "\";" << endl;
    96 	        t << "\t\t\t\tdefault_data = \"" << interfacename << "\";" << endl;
   145 	        t << "\t\t\t\t// SERVICE.CONFIGURATION" << endl;
    97 	        t << "\t\t\t\t// SERVICE.CONFIGURATION" << endl;
   146 	        t << "\t\t\t\topaque_data = \""; 
    98 	        t << "\t\t\t\topaque_data = \""; 
   147 			while( !configStream.atEnd() ) {
    99 			while( !configStream.atEnd() ) {
   148 				configStream.skipWhiteSpace();
   100 				configStream.skipWhiteSpace();
   149 				t << configStream.readLine( 255 ).replace("\"","\\\"");
   101 				t << configStream.readLine( 255 ).replace(QString::fromLatin1("\""), QString::fromLatin1("\\\""));
   150 			};
   102 			};
   151 			t << "\";" << endl;
   103 			t << "\";" << endl;
   152 	        t << "\t\t\t\t}" << endl << "\t\t\t};" << endl << "\t\t}" << endl << "\t};" << endl << "}" << endl;
   104 	        t << "\t\t\t\t}" << endl << "\t\t\t};" << endl << "\t\t}" << endl << "\t};" << endl << "}" << endl;
   153 			printf("Generated: ");
   105 			printf("Generated: ");
   154 			printf((QFileInfo(ft).absoluteFilePath()).toLocal8Bit().data() );
   106 			printf((QFileInfo(ft).absoluteFilePath()).toLocal8Bit().data() );
   168 void runXQPkgGenerator(QStringList params)
   120 void runXQPkgGenerator(QStringList params)
   169 {
   121 {
   170     QString appName = params[1];
   122     QString appName = params[1];
   171     QString uid3=params[2];
   123     QString uid3=params[2];
   172 	
   124 	
   173     QString outputFileName=appName+QString(".pkg");
   125     QString outputFileName=appName+QString(QString::fromLatin1(".pkg"));
   174 
   126 
   175     QFile ft(outputFileName);
   127     QFile ft(outputFileName);
   176 	if(!ft.exists()){
   128 	if(!ft.exists()){
   177 	    if(ft.open(QIODevice::WriteOnly)) {
   129 	    if(ft.open(QIODevice::WriteOnly)) {
   178 	        QTextStream t(&ft);
   130 	        QTextStream t(&ft);
   220 
   172 
   221 void runXQIbyGenerator(QStringList params)
   173 void runXQIbyGenerator(QStringList params)
   222 {
   174 {
   223     QString appName = params[1];
   175     QString appName = params[1];
   224 	
   176 	
   225     QString outputFileName=appName+QString(".iby");
   177     QString outputFileName=appName+QString(QString::fromLatin1(".iby"));
   226 	QString headerGuard = appName+QString("_IBY");
   178 	QString headerGuard = appName+QString(QString::fromLatin1("_IBY"));
   227 	headerGuard=headerGuard.toUpper();
   179 	headerGuard=headerGuard.toUpper();
   228 
   180 
   229     QFile ft(outputFileName);
   181     QFile ft(outputFileName);
   230 	if(!ft.exists()){
   182 	if(!ft.exists()){
   231 	    if(ft.open(QIODevice::WriteOnly)) {
   183 	    if(ft.open(QIODevice::WriteOnly)) {
   259 }
   211 }
   260 
   212 
   261 void runXQStubGenerator(QStringList params)
   213 void runXQStubGenerator(QStringList params)
   262 {
   214 {
   263     QString appName = params[1];
   215     QString appName = params[1];
   264     QString uid3=params[2];	
   216     QString uid3 = params[2];	
   265 	
   217 	
   266 	QString outputHeaderFileName="ecomstub_"+uid3+".hrh";
   218 	QString outputHeaderFileName=QString::fromLatin1("ecomstub_") + uid3 + QString::fromLatin1(".hrh");
   267 	QString outputSourceFileName="ecomstub_"+uid3+".cpp";
   219 	QString outputSourceFileName=QString::fromLatin1("ecomstub_") + uid3 + QString::fromLatin1(".cpp");
   268 	QString headerGuard = QString("ECOMSTUB_%1_HRH").arg(uid3);
   220 	QString headerGuard = QString::fromLatin1("ECOMSTUB_%1_HRH").arg(uid3);
   269 
   221 
   270     QFile fth(outputHeaderFileName);
   222     QFile fth(outputHeaderFileName);
   271 	if(!fth.exists()){
   223 	if(!fth.exists()){
   272 	    if(fth.open(QIODevice::WriteOnly)) {
   224 	    if(fth.open(QIODevice::WriteOnly)) {
   273 	        QTextStream t(&fth);
   225 	        QTextStream t(&fth);
   305 	        t << "// ============================================================================" << endl;
   257 	        t << "// ============================================================================" << endl;
   306 	        t << endl;
   258 	        t << endl;
   307 	        
   259 	        
   308 			t << "#include <xqplugin.h>" << endl;
   260 			t << "#include <xqplugin.h>" << endl;
   309 	        t << "#include <" << outputHeaderFileName << ">" << endl;
   261 	        t << "#include <" << outputHeaderFileName << ">" << endl;
   310 	        t << "#include <ecom/ImplementationProxy.h>" << endl;
   262 	        t << "#include <ecom/implementationproxy.h>" << endl;
   311 	        t << "XQ_PLUGIN_ECOM_HEADER(" << appName << ")" << endl;
   263 	        t << "XQ_PLUGIN_ECOM_HEADER(" << appName << ")" << endl;
   312 	        //t << "const TImplementationProxy implementationTable[] = \n\t{\n\tIMPLEMENTATION_PROXY_ENTRY( " << IMPLEMENTATION_UID_LIT << ", C" 
   264 	        //t << "const TImplementationProxy implementationTable[] = \n\t{\n\tIMPLEMENTATION_PROXY_ENTRY( " << IMPLEMENTATION_UID_LIT << ", C" 
   313 			t << "const TImplementationProxy implementationTable[] = \n\t{\n\tIMPLEMENTATION_PROXY_ENTRY(" + uid3 + ", C" 
   265 			
       
   266 			t << "const TImplementationProxy implementationTable[] = \n\t{\n\tIMPLEMENTATION_PROXY_ENTRY(" << uid3 << ", C" 
   314 			  << appName
   267 			  << appName
   315 	          <<"Factory::NewL)\n\t};" << endl << endl;
   268 	          <<"Factory::NewL)\n\t};" << endl << endl;
       
   269 			  
   316 	        t << "EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)"
   270 	        t << "EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)"
   317 	          << endl <<"\t{\n\taTableCount = sizeof( implementationTable ) / sizeof( TImplementationProxy );"
   271 	          << endl <<"\t{\n\taTableCount = sizeof( implementationTable ) / sizeof( TImplementationProxy );"
   318 	          << endl <<"\treturn implementationTable;"
   272 	          << endl <<"\treturn implementationTable;"
   319 	          << endl <<"\t}" << endl;
   273 	          << endl <<"\t}" << endl;
   320 			printf("Generated: ");
   274 			printf("Generated: ");
   334 
   288 
   335 int main(int argc, char *argv[])
   289 int main(int argc, char *argv[])
   336 {
   290 {
   337     QStringList params;
   291     QStringList params;
   338     for (int i=0 ; i < argc ; i++) {
   292     for (int i=0 ; i < argc ; i++) {
   339         params << argv[i];
   293         params << QString::fromLatin1(argv[i]);
   340 //		printf(argv[i]);
   294 //		printf(argv[i]);
   341 //		printf("\n");
   295 //		printf("\n");
   342 //		fprintf(stderr, "%s\n",argv[i]);
   296 //		fprintf(stderr, "%s\n",argv[i]);
   343    }
   297    }
   344 	if (params.count() < 6) {
   298 	if (params.count() < 6) {
   345         fprintf(stderr, "xqecom error: invalid parameters(%d)! ",params.count());
   299         fprintf(stderr, "xqecom error: invalid parameters(%d)! ",params.count());
   346         fprintf(stderr, "Usage: xqecom <app name> <uid3> <interface name> <configuration> <configuration-filename>\n");
   300         fprintf(stderr, "Usage: xqecom <app name> <uid3> <interface name> <configuration> <configuration-filename>\n");
   347         return 1;
   301         return 1;
   348     }
   302     }
   349 	
   303 	
   350 	if ( !params[2].startsWith("0x") ){ //fix uid if incorrect
   304 	if ( !params[2].startsWith(QString::fromLatin1("0x")) ){ //fix uid if incorrect
   351 		params[2].insert( 0, "0x");
   305 		params[2].insert( 0, QString::fromLatin1("0x"));
   352 	}
   306 	}
   353 
   307 
   354     printf("xqecom:\n");
   308     printf("xqecom:\n");
   355 	runDefFileGenerator();
       
   356 	runRSSFileGenerator(params);
   309 	runRSSFileGenerator(params);
   357 	runXQPkgGenerator(params);
   310 	runXQPkgGenerator(params);
   358 	runXQIbyGenerator(params);
   311 	runXQIbyGenerator(params);
   359 	runXQStubGenerator(params);
   312 	runXQStubGenerator(params);
   360 	
   313