smf/smfservermodule/smfserver/pluginmgr/smfpluginmanager.cpp
changeset 26 83d6a149c755
parent 25 a180113055cb
equal deleted inserted replaced
25:a180113055cb 26:83d6a149c755
   354 			else
   354 			else
   355 				{
   355 				{
   356 				qDebug()<<"Plugin responseAvailable() failed!!!, error = "<<retValue;
   356 				qDebug()<<"Plugin responseAvailable() failed!!!, error = "<<retValue;
   357 				
   357 				
   358 				// Error in parsing, sent to server
   358 				// Error in parsing, sent to server
   359 // ToDo :- For testing:-
       
   360 				stream<<result.toString();
   359 				stream<<result.toString();
   361 				m_server->resultsAvailable(sessionId, &arr, retValue);
   360 				m_server->resultsAvailable(sessionId, &arr, retValue);
   362 			}
   361 			}
   363 		}
   362 		}
   364 	else
   363 	else
   469 	QSqlQuery query;
   468 	QSqlQuery query;
   470 	bool tableCreated = false;
   469 	bool tableCreated = false;
   471 
   470 
   472 	tableCreated = query.exec("CREATE TABLE IF NOT EXISTS pluginDetails ("
   471 	tableCreated = query.exec("CREATE TABLE IF NOT EXISTS pluginDetails ("
   473 			"pluginId TEXT PRIMARY KEY, interfaceName TEXT, serviceProvider TEXT, "
   472 			"pluginId TEXT PRIMARY KEY, interfaceName TEXT, serviceProvider TEXT, "
   474 			"description TEXT, serviceUrl TEXT, authAppId TEXT)");
   473 			"description TEXT, serviceUrl TEXT, authAppId TEXT, authAppName TEXT)");
   475 
   474 
   476 	// Error - table not created, Plugin Manager might not work properly
   475 	// Error - table not created, Plugin Manager might not work properly
   477 	if(!tableCreated)
   476 	if(!tableCreated)
   478 		{
   477 		{
   479 		qDebug()<<"Table not created!!!, error = "<<query.lastError().text();
   478 		qDebug()<<"Table not created!!!, error = "<<query.lastError().text();
   543 						QString desc = plugin->getProviderInfo()->description();
   542 						QString desc = plugin->getProviderInfo()->description();
   544 						
   543 						
   545 						// get the service URL
   544 						// get the service URL
   546 						QString servURL = plugin->getProviderInfo()->serviceUrl().toString();
   545 						QString servURL = plugin->getProviderInfo()->serviceUrl().toString();
   547 						
   546 						
       
   547 						// get the auth application process name
       
   548 						QString authAppName = plugin->getProviderInfo()->authenticationAppName();
       
   549 								
   548 						// get the authentication application id
   550 						// get the authentication application id
   549 						QString str;
   551 						QString str;
   550 						QStringList list;
   552 						QStringList list;
   551 						QString authAppId = plugin->getProviderInfo()->authenticationApp(
   553 						QString authAppId = plugin->getProviderInfo()->authenticationApp(
   552 								str, list, QIODevice::ReadWrite);
   554 								str, list, QIODevice::ReadWrite);
   555 						m_pluginIdPathHash.insert(id, dir.absoluteFilePath(pluginName));
   557 						m_pluginIdPathHash.insert(id, dir.absoluteFilePath(pluginName));
   556 						
   558 						
   557 						QSqlQuery rowInsertQuery;
   559 						QSqlQuery rowInsertQuery;
   558 						
   560 						
   559 						// insert into database
   561 						// insert into database
   560 						bool rowInserted = rowInsertQuery.exec(QString("INSERT INTO pluginDetails VALUES ('%1', "
   562 						bool rowInserted = rowInsertQuery.exec(QString("INSERT INTO pluginDetails VALUES ("
   561 								"'%2', '%3', '%4', '%5', '%6')").arg(id).arg(intfImplemented).arg(serProv)
   563 								"'%1', '%2', '%3', '%4', '%5', '%6', '%7')").arg(id).arg(intfImplemented)
   562 								.arg(desc).arg(servURL).arg(authAppId));
   564 								.arg(serProv).arg(desc).arg(servURL).arg(authAppId).arg(authAppName));
   563 						
   565 						
   564 						if(rowInserted)
   566 						if(rowInserted)
   565 							qDebug()<<QString("This Plugin's information is added to database : '%1' '%2' '%3'")
   567 							qDebug()<<QString("This Plugin's information is added to database : '%1' '%2' '%3' '%4'")
   566 											.arg(id).arg(intfImplemented).arg(serProv);
   568 											.arg(id).arg(intfImplemented).arg(serProv).arg(authAppId);
   567 						else
   569 						else
       
   570 							{
       
   571 							qDebug()<<"Data base insert statement returned = "<<rowInserted;
   568 							if(0 != query.lastError().text().size())
   572 							if(0 != query.lastError().text().size())
   569 								qDebug()<<"plugins data not written to database!!!, error = "<<query.lastError().text();
   573 								qDebug()<<"plugins data not written to database!!!, error = "<<query.lastError().text();
       
   574 							}
   570 				    	}
   575 				    	}
   571 				    else
   576 				    else
   572 				    	{
   577 				    	{
   573 						qDebug()<<"Plugin could not be converted to SmfpluginBase* - returning!!!";
   578 						qDebug()<<"Plugin could not be converted to SmfpluginBase* - returning!!!";
   574 						
   579 						
   592 				}
   597 				}
   593 			dir.cdUp();
   598 			dir.cdUp();
   594 			}
   599 			}
   595 		}
   600 		}
   596 	else
   601 	else
   597 		qDebug()<<"No Smf plugins installed!!!";
   602 		{
       
   603 			qDebug()<<"No Smf plugins installed!!!";
       
   604 			return false;
       
   605 		}
       
   606 	
   598 	
   607 	
   599 	// Close the database
   608 	// Close the database
   600 	m_pluginDataBase.close();
   609 	m_pluginDataBase.close();
   601 	
   610 	
   602 	return true;
   611 	return true;
   906 	QString pluginId;
   915 	QString pluginId;
   907 	QString oldpluginId;
   916 	QString oldpluginId;
   908 	QString interfaceName;
   917 	QString interfaceName;
   909 	QString serviceProv;
   918 	QString serviceProv;
   910 	QString authAppId;
   919 	QString authAppId;
       
   920 	QString authAppName;
   911 
   921 
   912 	// Get all the files in the directory at a specified path(sorted)
   922 	// Get all the files in the directory at a specified path(sorted)
   913 	QStringList newPlugins = dir.entryList(QDir::Files, QDir::Name);
   923 	QStringList newPlugins = dir.entryList(QDir::Files, QDir::Name);
   914 	QStringList::const_iterator newListIterator = newPlugins.constBegin();
   924 	QStringList::const_iterator newListIterator = newPlugins.constBegin();
   915 	
   925 	
  1017 			interfaceName = dir.dirName();
  1027 			interfaceName = dir.dirName();
  1018 			interfaceName.prepend("org.symbian.smf.plugin.");
  1028 			interfaceName.prepend("org.symbian.smf.plugin.");
  1019 			QString prgm;
  1029 			QString prgm;
  1020 			QStringList list;
  1030 			QStringList list;
  1021 			authAppId = instance->getProviderInfo()->authenticationApp(prgm, list, QIODevice::ReadWrite);
  1031 			authAppId = instance->getProviderInfo()->authenticationApp(prgm, list, QIODevice::ReadWrite);
       
  1032 			authAppName = instance->getProviderInfo()->authenticationAppName();
  1022 			}
  1033 			}
  1023 		
  1034 		
  1024 		unload(instance);
  1035 		unload(instance);
  1025 		
  1036 		
  1026 		// Also add to the database the value newListIterator and aPath
  1037 		// Also add to the database the value newListIterator and aPath
  1027 		QSqlQuery insertRowQuery;
  1038 		QSqlQuery insertRowQuery;
  1028 		bool rowInserted = insertRowQuery.exec(QString("INSERT INTO pluginDetails VALUES "
  1039 		bool rowInserted = insertRowQuery.exec(QString("INSERT INTO pluginDetails VALUES "
  1029 				"('%1', '%2', '%3', '%4')").arg(pluginId).arg(interfaceName).arg(serviceProv).arg(authAppId));
  1040 				"('%1', '%2', '%3', '%4', '%5')").arg(pluginId).arg(interfaceName).arg(serviceProv).arg(authAppId).arg(authAppName));
  1030 
  1041 
  1031 		 // Error
  1042 		 // Error
  1032 		if (!rowInserted)
  1043 		if (!rowInserted)
  1033 			qDebug()<<"Database table not inserted, error = "<<insertRowQuery.lastError().text();
  1044 			qDebug()<<"Database table not inserted, error = "<<insertRowQuery.lastError().text();
  1034 		
  1045 		
  1131 	qDebug()<<"Data base opened";
  1142 	qDebug()<<"Data base opened";
  1132 #endif
  1143 #endif
  1133 	
  1144 	
  1134 	// Query the database for all pluginIDs that implement the given interface
  1145 	// Query the database for all pluginIDs that implement the given interface
  1135 	QSqlQuery query(QString("SELECT pluginId, interfaceName, serviceProvider, description, "
  1146 	QSqlQuery query(QString("SELECT pluginId, interfaceName, serviceProvider, description, "
  1136 			"serviceUrl FROM pluginDetails where interfaceName = '%1'").arg(aInterface));
  1147 			"serviceUrl, authAppId, authAppName FROM pluginDetails where interfaceName = '%1'").arg(aInterface));
  1137 	
  1148 	
  1138 	while(query.next())
  1149 	while(query.next())
  1139 		{
  1150 		{
  1140 #ifdef DETAILEDDEBUGGING
  1151 #ifdef DETAILEDDEBUGGING
  1141 		qDebug()<<"Query is success";
  1152 		qDebug()<<"Query is success";
  1172 		// Get the service URL
  1183 		// Get the service URL
  1173 		QUrl url(query.value(4).toString());
  1184 		QUrl url(query.value(4).toString());
  1174 		prov.setServiceUrl(url);
  1185 		prov.setServiceUrl(url);
  1175 #ifdef DETAILEDDEBUGGING
  1186 #ifdef DETAILEDDEBUGGING
  1176 		qDebug()<<"  Its url = "<<url.toString();
  1187 		qDebug()<<"  Its url = "<<url.toString();
       
  1188 #endif
       
  1189 
       
  1190 		// Get the auth app ID
       
  1191 		QString id(query.value(5).toString());
       
  1192 		prov.setAuthenticationAppId(id);
       
  1193 #ifdef DETAILEDDEBUGGING
       
  1194 		qDebug()<<"  Its auth app id = "<<id;
       
  1195 #endif
       
  1196 		
       
  1197 		// Get the auth app name
       
  1198 		QString name (query.value(6).toString());
       
  1199 		prov.setAuthenticationAppName(name);
       
  1200 #ifdef DETAILEDDEBUGGING
       
  1201 		qDebug()<<"  Its auth app name = "<<name;
  1177 #endif
  1202 #endif
  1178 
  1203 
  1179 		aMap.insert(pluginId, prov);
  1204 		aMap.insert(pluginId, prov);
  1180 		}
  1205 		}
  1181 	
  1206