example/smfclientapp/displaywidget.cpp
changeset 14 a469c0e6e7fb
parent 6 c39a6cfd1fb9
child 17 106a4bfcb866
equal deleted inserted replaced
13:b5d63d5fc252 14:a469c0e6e7fb
    20 #include <QDesktopWidget>
    20 #include <QDesktopWidget>
    21 
    21 
    22 DisplayWidget::DisplayWidget(QWidget *parent)
    22 DisplayWidget::DisplayWidget(QWidget *parent)
    23     : QWidget(parent)
    23     : QWidget(parent)
    24 {
    24 {
    25 	ui.setupUi(this);
    25 //	ui.setupUi(this);
    26 	ui.verticalLayout->setGeometry(QApplication::desktop()->availableGeometry());
    26 //	ui.verticalLayout->setGeometry(QApplication::desktop()->availableGeometry());
    27 	//Add item as and when they are implemented
    27 //	//Add item as and when they are implemented
    28 	ui.comboBox_intf->addItem("Contact Fetcher");
    28 //	ui.comboBox_intf->addItem("Contact Fetcher");
    29 	ui.comboBox_intf->addItem("Post Provider");
    29 //	ui.comboBox_intf->addItem("Post Provider");
    30 //	connect(ui.comboBox_intf,
    30 ////	connect(ui.comboBox_intf,
    31 //			SIGNAL(currentIndexChanged(int)),
    31 ////			SIGNAL(currentIndexChanged(int)),
    32 //			this,
    32 ////			this,
    33 //			SLOT(interfaceSelected(int)));
    33 ////			SLOT(interfaceSelected(int)));
    34 	connect(ui.pushButton_intf,SIGNAL(clicked()),this,SLOT(interfaceSelected()));
    34 //	connect(ui.pushButton_intf,SIGNAL(clicked()),this,SLOT(interfaceSelected()));
    35 	connect(ui.pushButton_SP,SIGNAL(clicked()),this,SLOT(serviceProviderSelected()));
    35 //	connect(ui.pushButton_SP,SIGNAL(clicked()),this,SLOT(serviceProviderSelected()));
    36 	connect(ui.pushButton_service,SIGNAL(clicked()),this,SLOT(serviceSelected()));
    36 //	connect(ui.pushButton_service,SIGNAL(clicked()),this,SLOT(serviceSelected()));
    37 	writeLog("Start");
    37 //	writeLog("Start");
       
    38 	SmfClient client;
       
    39 	QString intfName("org.symbian.smf.client.contact.fetcher\0.2");
       
    40 	providerList= client.GetServices(intfName);
       
    41 	writeLog("GetServices count=");
       
    42 	QString c = QString::number(providerList->count());
       
    43 	writeLog(c);	
       
    44 	SmfProvider smfP(providerList->at(0));
       
    45 	m_contactFetcher = new SmfContactFetcher(&smfP);
       
    46 				//connect to appropriate slot
       
    47 	connect(m_contactFetcher,
       
    48 			SIGNAL(friendsListAvailable(SmfContactList*, SmfError , SmfResultPage)),
       
    49 			this,
       
    50 			SLOT(showFriends(SmfContactList*, SmfError , SmfResultPage)));
       
    51 	
       
    52 	writeLog("Before m_contactFetcher->friends=");
       
    53 	//request for friends, excluding paging info
       
    54 	m_contactFetcher->friends();
    38 }
    55 }
    39 void DisplayWidget::interfaceSelected()
    56 void DisplayWidget::interfaceSelected()
    40 	{
    57 	{
    41 	SmfClient client;
    58 	SmfClient client;
    42 	//TODO:- PM should use commented interface name instead
       
    43 //	QString name("org.symbian.smf.client.contact.posts");
       
    44 	QString intfName;
    59 	QString intfName;
    45 	switch(ui.comboBox_intf->currentIndex())
    60 	switch(ui.comboBox_intf->currentIndex())
    46 		{
    61 		{
    47 		case 0:
    62 		case 0:
    48 			intfName = "org.symbian.smf.client.contact.fetcher";
    63 			intfName = "org.symbian.smf.client.contact.fetcher";
    49 			break;
    64 			break;
    50 		case 1:
    65 		case 1:
    51 			intfName = "posts";
    66 			intfName = "org.symbian.smf.client.contact.posts";
    52 			break;
    67 			break;
    53 		default:
    68 		default:
    54 			//should not reach here!!!!
    69 			//should not reach here!!!!
    55 			break;
    70 			break;
    56 		}
    71 		}
    96 void DisplayWidget::serviceSelected()
   111 void DisplayWidget::serviceSelected()
    97 	{
   112 	{
    98 	SmfProvider smfP(providerList->at(ui.comboBox_service->currentIndex()));
   113 	SmfProvider smfP(providerList->at(ui.comboBox_service->currentIndex()));
    99 	
   114 	
   100 	writeLog("Selected SmfProvider=");
   115 	writeLog("Selected SmfProvider=");
   101 	writeLog(smfP.m_description);
   116 	writeLog(smfP.description());
   102 	writeLog(smfP.m_serviceUrl.toString());
   117 	writeLog(smfP.serviceUrl().toString());
   103 	writeLog(smfP.m_appUrl.toString());
   118 	writeLog(smfP.applicationUrl().toString());
   104 	switch(ui.comboBox_intf->currentIndex())
   119 	switch(ui.comboBox_intf->currentIndex())
   105 		{
   120 		{
   106 		case 1:
   121 		case 1:
   107 			m_postProvider = new SmfPostProvider(&smfP);
   122 			m_postProvider = new SmfPostProvider(&smfP);
   108 			//TODO:- it should be nested switch case as there are multiple APIs under one interface
   123 			//TODO:- it should be nested switch case as there are multiple APIs under one interface
   146 		QMessageBox::information(this,"Error",smferrString,QMessageBox::Ok);
   161 		QMessageBox::information(this,"Error",smferrString,QMessageBox::Ok);
   147 		}
   162 		}
   148 	//display post description
   163 	//display post description
   149 	
   164 	
   150 	foreach(SmfPost post, *postlist)
   165 	foreach(SmfPost post, *postlist)
   151 			{
   166 			{ 
   152 			QString desc = post.description();
   167 			QString desc = post.description();
   153 			ui.listWidget->addItem(desc);
   168 			ui.listWidget->addItem(desc);
   154 			}
   169 			}
   155 	ui.listWidget->show();
   170 	ui.listWidget->show();
   156 	}
   171 	}
   163 	writeLog(QString::number(err));
   178 	writeLog(QString::number(err));
   164 	//display friends
   179 	//display friends
   165 	
   180 	
   166 	foreach(SmfContact frnd, *frnds)
   181 	foreach(SmfContact frnd, *frnds)
   167 			{
   182 			{
   168 		//lets display only street
   183 		//lets display only name
   169 		QVariant nameVar = frnd.value("Name");
   184 		QVariant nameVar = frnd.value("Name");
   170 		QContactName name = nameVar.value<QContactName>();
   185 		QContactName name = nameVar.value<QContactName>();
   171 		QString fname;
   186 		QString fname;
   172 		QString lname;
   187 		QString lname;
   173 #ifdef OLDER_QT_MOBILITY
       
   174 		fname = name.first();
       
   175 		lname = name.last();
       
   176 #else
       
   177 		fname = name.firstName();
   188 		fname = name.firstName();
   178 		lname = name.lastName();
   189 		lname = name.lastName();
   179 #endif
   190 		//qDebug()<<fname;
   180 		
   191 		//qDebug()<<lname;
   181 		ui.listWidget->addItem(fname);
   192 		//ui.listWidget->addItem(fname);
   182 			}
   193 			}
   183 	ui.listWidget->show();
   194 	//ui.listWidget->show();
   184 	}
   195 	}
   185 void DisplayWidget::writeLog(QString log) const
   196 void DisplayWidget::writeLog(QString log) const
   186 	{
   197 	{
   187 #ifdef WRITE_LOG 
   198 #ifdef WRITE_LOG 
   188 	QFile file("c:\\data\\SmfClientLogs.txt");
   199 	QFile file("c:\\data\\SmfClientLogs.txt");