21
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
#include "zeroconfsharing.h"
|
|
18 |
#include <mdns/mdnsparamset.h>
|
|
19 |
|
|
20 |
#include <QtGui/QListWidget>
|
|
21 |
#include <QVBoxLayout>
|
|
22 |
#include <QtNetwork>
|
|
23 |
#include <QNetworkRequest>
|
|
24 |
#include <QNetworkReply>
|
|
25 |
|
|
26 |
#ifdef Q_OS_SYMBIAN
|
|
27 |
#include "sym_iap_util.h"
|
|
28 |
#endif
|
|
29 |
#include "bjrhttpserver.h"
|
|
30 |
|
|
31 |
#include "contactinfo.h"
|
|
32 |
#include "cfileparser.h"
|
|
33 |
#include "cfilelistengine.h"
|
|
34 |
#include "downloadicon.h"
|
|
35 |
_LIT8(KFileName,"E:\\logs\\temp.txt");
|
|
36 |
|
|
37 |
_LIT8(KMyStatusFile,"E:\\MyStatus.txt");
|
|
38 |
const int KMaxLength = 256;
|
|
39 |
_LIT8(KLogFile,"E:\\logs\\uilog.txt");
|
|
40 |
|
|
41 |
QZeroConfSharingUi::QZeroConfSharingUi(QWidget *parent)
|
|
42 |
: QMainWindow(parent)
|
|
43 |
{
|
|
44 |
ui.setupUi(this);
|
|
45 |
|
|
46 |
isShared = false;
|
|
47 |
|
|
48 |
tabWidget = new QTabWidget(this);
|
|
49 |
tabWidget->hide();
|
|
50 |
|
|
51 |
shareAction = new QAction(tr("Share"), this);
|
|
52 |
connect(shareAction, SIGNAL(triggered()), this, SLOT(StartServer()));
|
|
53 |
|
|
54 |
unshareAction = new QAction(tr("UnShare"), this);
|
|
55 |
connect(unshareAction, SIGNAL(triggered()), this, SLOT(StopServer()));
|
|
56 |
|
|
57 |
menuBar()->addAction(shareAction);
|
|
58 |
#ifdef Q_OS_SYMBIAN
|
|
59 |
qt_SetDefaultIap();
|
|
60 |
#endif
|
|
61 |
|
|
62 |
manager = new QNetworkAccessManager(this);
|
|
63 |
|
|
64 |
#ifndef __arm
|
|
65 |
PopulateCommunityList();
|
|
66 |
PopulateCommunityList();
|
|
67 |
PopulateCommunityList();
|
|
68 |
PopulateCommunityList();
|
|
69 |
PopulateCommunityList();
|
|
70 |
#endif
|
|
71 |
// Hide the Contact Tab
|
|
72 |
ui.tabWidget->removeTab(0);
|
|
73 |
// Hide the Chat tab
|
|
74 |
ui.tabWidget->removeTab(4);
|
|
75 |
// Hide the File Share Tab
|
|
76 |
ui.treeContactMusic->setVisible(false);
|
|
77 |
ui.treeContactMusic_2->setVisible(false);
|
|
78 |
ui.treeContactMusic_3->setVisible(false);
|
|
79 |
|
|
80 |
ShowBackButtons(false);
|
|
81 |
// Layout
|
|
82 |
QVBoxLayout *layout = new QVBoxLayout;
|
|
83 |
layout->addWidget(ui.tabWidget);
|
|
84 |
setLayout(layout);
|
|
85 |
|
|
86 |
|
|
87 |
ui.tabWidget->setContextMenuPolicy(Qt::NoContextMenu);
|
|
88 |
ui.tabWidget->showMaximized();
|
|
89 |
|
|
90 |
connect(ui.listAvatars, SIGNAL(itemClicked(QListWidgetItem *)),
|
|
91 |
this, SLOT(on_listAvatars_itemClicked(QListWidgetItem *)));
|
|
92 |
|
|
93 |
ui.tabWidget->setCurrentIndex(0);
|
|
94 |
|
|
95 |
connect(ui.StatusUpdatebtn, SIGNAL(pressed()),this,SLOT(UpdateMyStatus()));
|
|
96 |
connect(ui.pushBackContact, SIGNAL(clicked ()), this, SLOT(backPressed()));
|
|
97 |
connect(ui.pushBackPhoto, SIGNAL(clicked ()), this, SLOT(backPressed()));
|
|
98 |
connect(ui.pushBackVideo, SIGNAL(clicked ()), this, SLOT(backPressed()));
|
|
99 |
connect(ui.pushBackChat, SIGNAL(clicked ()), this, SLOT(backPressed()));
|
|
100 |
connect(ui.pushBackMusic, SIGNAL(clicked ()), this, SLOT(backPressed()));
|
|
101 |
|
|
102 |
connect(ui.treeContactMusic_2, SIGNAL(itemClicked(QTreeWidgetItem* , int)), this, SLOT(ContactitemClicked(QTreeWidgetItem* , int)));
|
|
103 |
connect(ui.treeContactMusic, SIGNAL(itemClicked(QTreeWidgetItem* , int)), this, SLOT(ContactitemClicked(QTreeWidgetItem* , int)));
|
|
104 |
connect(ui.treeContactMusic_3, SIGNAL(itemClicked(QTreeWidgetItem* , int)), this, SLOT(ContactitemClicked(QTreeWidgetItem* , int)));
|
|
105 |
|
|
106 |
//Open the status file
|
|
107 |
QString mystatusfile = QString::fromUtf8((const char*)KMyStatusFile().Ptr(),KMyStatusFile().Length());
|
|
108 |
bool doesExist = MyStatusFile.exists(mystatusfile);
|
|
109 |
MyStatusFile.setFileName(mystatusfile);
|
|
110 |
//file already exists...get the status from file
|
|
111 |
MyStatusFile.open( QIODevice::ReadOnly|QIODevice::Text );
|
|
112 |
//opened in write only mode so that status updates can be
|
|
113 |
//reflected in the file
|
|
114 |
QByteArray str = MyStatusFile.readAll();
|
|
115 |
QString filestr(str);
|
|
116 |
nowStatus = filestr;
|
|
117 |
|
|
118 |
ui.MyStatusLabel->setText(nowStatus);
|
|
119 |
|
|
120 |
//convert nowSttaus to Rbuf8
|
|
121 |
TPtrC ptrName(reinterpret_cast<const TText*>(nowStatus.constData()));
|
|
122 |
|
|
123 |
iStatus.CreateL(ptrName.Length());
|
|
124 |
iStatus.Copy(ptrName);
|
|
125 |
|
|
126 |
|
|
127 |
iZeroConfClient = CZeroconfClient::NewL(this);
|
|
128 |
iZeroConfClient->ConnectL();
|
|
129 |
|
|
130 |
iNewContact = NULL;
|
|
131 |
MyStatusFile.close();
|
|
132 |
|
|
133 |
iStatusUpdate =EFalse;
|
|
134 |
|
|
135 |
iMusic = CMusicProvider::NewL(this);
|
|
136 |
iUpdate = EFalse;
|
|
137 |
iMusic->RequestMediaL();
|
|
138 |
|
|
139 |
DiscoverServices();
|
|
140 |
|
|
141 |
progressBar = NULL;
|
|
142 |
//IsDownloadItem = false;
|
|
143 |
|
|
144 |
logFile.setFileName("C:\\Data\\logs\\ZeroConfSharingui_log.txt");
|
|
145 |
logFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
|
146 |
|
|
147 |
logFile.write("Logging Starts");
|
|
148 |
logFile.close();
|
|
149 |
|
|
150 |
|
|
151 |
}
|
|
152 |
|
|
153 |
void QZeroConfSharingUi::Log(const char* msg)
|
|
154 |
{
|
|
155 |
|
|
156 |
logFile.open(QIODevice::Append);
|
|
157 |
logFile.write(msg, qstrlen(msg));
|
|
158 |
logFile.close();
|
|
159 |
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
void QZeroConfSharingUi::ContactitemClicked(QTreeWidgetItem* item, int /*column*/)
|
|
164 |
{
|
|
165 |
|
|
166 |
TPtrC ptrName(reinterpret_cast<const TText*>(iSelectedContact.constData()));
|
|
167 |
|
|
168 |
RBuf8 contactName;
|
|
169 |
contactName.Create(ptrName.Length());
|
|
170 |
contactName.Copy(ptrName);
|
|
171 |
|
|
172 |
//Find if its an already existing contact
|
|
173 |
CContactInfo* contact = GetSelectedContact(contactName);
|
|
174 |
if(contact!=NULL)
|
|
175 |
{
|
|
176 |
//IsDownloadItem = true;
|
|
177 |
RBuf8 url;
|
|
178 |
url.Create(KMaxLength);
|
|
179 |
url.Copy(contact->BaseUrl());
|
|
180 |
|
|
181 |
TPtrC fileItemName(reinterpret_cast<const TText*>((item->text(0)).constData()));
|
|
182 |
|
|
183 |
RBuf8 fileName;
|
|
184 |
fileName.Create(fileItemName.Length());
|
|
185 |
fileName.Copy(fileItemName);
|
|
186 |
|
|
187 |
url.Append(fileName);
|
|
188 |
|
|
189 |
QString qurl = QString::fromUtf8((const char*)url.Ptr(),url.Length());
|
|
190 |
|
|
191 |
iSelectedFileName = QString::fromUtf8((const char*)(contact->FilePath(fileName)).Ptr(),(contact->FilePath(fileName)).Length());
|
|
192 |
|
|
193 |
progressBar = new QProgressDialog(tr("Retrieving Shared Content"), tr("Cancel"), 0, 0);
|
|
194 |
connect(progressBar, SIGNAL(canceled()), this, SLOT(ProgressBarCanceled()));
|
|
195 |
progressBar->show();
|
|
196 |
|
|
197 |
itemReply = manager->get(QNetworkRequest(QUrl(qurl)));
|
|
198 |
|
|
199 |
connect(itemReply, SIGNAL(finished()), this, SLOT(ItemRequestFinished()));
|
|
200 |
|
|
201 |
fileName.Close();
|
|
202 |
url.Close();
|
|
203 |
|
|
204 |
}
|
|
205 |
contactName.Close();
|
|
206 |
|
|
207 |
}
|
|
208 |
|
|
209 |
|
|
210 |
void QZeroConfSharingUi::UpdateMyStatus()
|
|
211 |
{
|
|
212 |
//get the Text entered by the user in the status update
|
|
213 |
//text box
|
|
214 |
//& display it in the MyStatus label button
|
|
215 |
|
|
216 |
QString mystatusfile = QString::fromUtf8((const char*)KMyStatusFile().Ptr(),KMyStatusFile().Length());
|
|
217 |
bool doesExist = MyStatusFile.exists(mystatusfile);
|
|
218 |
MyStatusFile.setFileName(mystatusfile);
|
|
219 |
|
|
220 |
MyStatusFile.open( QIODevice::WriteOnly |QIODevice::Text );
|
|
221 |
QString currentStatus = ui.StatusTextBox->toPlainText();
|
|
222 |
//set the MyStatusLabel with this text
|
|
223 |
ui.MyStatusLabel->setText(currentStatus);
|
|
224 |
nowStatus = currentStatus;
|
|
225 |
TPtrC ptrName(reinterpret_cast<const TText*>(nowStatus.constData()));
|
|
226 |
|
|
227 |
RBuf8 current;
|
|
228 |
current.Create(ptrName.Length());
|
|
229 |
current.Copy(ptrName);
|
|
230 |
if(iStatusUpdate)
|
|
231 |
{
|
|
232 |
iZeroConfClient->UpdateCurrentStatusServiceL(current);
|
|
233 |
}
|
|
234 |
else
|
|
235 |
{
|
|
236 |
iZeroConfClient->PublishCurrentStatusServiceL(current);
|
|
237 |
iStatusUpdate =ETrue;
|
|
238 |
}
|
|
239 |
|
|
240 |
int errval = MyStatusFile.write(nowStatus.toUtf8());
|
|
241 |
MyStatusFile.close();
|
|
242 |
current.Close();
|
|
243 |
ui.StatusTextBox->clear();
|
|
244 |
//send an update record at Bonjour-level
|
|
245 |
|
|
246 |
}
|
|
247 |
|
|
248 |
void QZeroConfSharingUi::PopulateCommunityList()
|
|
249 |
{
|
|
250 |
static int i = 0;
|
|
251 |
QString path, name;
|
|
252 |
switch(i)
|
|
253 |
{
|
|
254 |
case 0: path = ":/Images/Vivek"; name = "Vivek";break;
|
|
255 |
case 1: path = ":/Images/Unknown"; name = "Vadan";break;
|
|
256 |
case 2: path = ":/Images/Guru"; name = "Guru"; break;
|
|
257 |
case 3: path = ":/Images/Sampo"; name = "Sampo";break;
|
|
258 |
case 4: path = ":/Images/Unknown"; name = "Sindhu";break;
|
|
259 |
default: break;
|
|
260 |
}
|
|
261 |
i++;
|
|
262 |
QListWidgetItem* item = new QListWidgetItem(QIcon(path), name);
|
|
263 |
ui.listAvatars->addItem(item);
|
|
264 |
}
|
|
265 |
|
|
266 |
void QZeroConfSharingUi::PopulateUserList()
|
|
267 |
{
|
|
268 |
}
|
|
269 |
void QZeroConfSharingUi::backPressed()
|
|
270 |
{
|
|
271 |
ShowAllContacts(true);
|
|
272 |
setWindowTitle(QApplication::translate("MainWindow", "Local Sharing", 0, QApplication::UnicodeUTF8));
|
|
273 |
|
|
274 |
ui.treeContactMusic->setVisible(false);
|
|
275 |
ui.treeContactMusic_2->setVisible(false);
|
|
276 |
ui.treeContactMusic_3->setVisible(false);
|
|
277 |
|
|
278 |
ui.treeMusicAll_3->setVisible(true);
|
|
279 |
ui.treeMusicAll->setVisible(true);
|
|
280 |
ui.treeMusicAll_2->setVisible(true);
|
|
281 |
|
|
282 |
}
|
|
283 |
|
|
284 |
void QZeroConfSharingUi::PopulateContactSpecificData()
|
|
285 |
{
|
|
286 |
|
|
287 |
TPtrC ptrName(reinterpret_cast<const TText*>(iSelectedContact.constData()));
|
|
288 |
RBuf8 iname,mname,vname,fname;
|
|
289 |
RBuf8 contactName;
|
|
290 |
contactName.Create(ptrName.Length());
|
|
291 |
contactName.Copy(ptrName);
|
|
292 |
//Find if its an already existing contact
|
|
293 |
#ifdef __arm
|
|
294 |
CContactInfo* contact = GetSelectedContact(contactName);
|
|
295 |
if(contact!=NULL)
|
|
296 |
#endif
|
|
297 |
{
|
|
298 |
//invoke the parser
|
|
299 |
#ifdef __arm
|
|
300 |
fname.CreateL(contact->FileListPath(_L8("filelist.txt")));
|
|
301 |
|
|
302 |
iname.CreateL(contact->ImgFileName());
|
|
303 |
mname.CreateL(contact->MusicFileName());
|
|
304 |
vname.CreateL(contact->VideoFileName());
|
|
305 |
|
|
306 |
#else
|
|
307 |
_LIT8(KFileListName,"c:\\data\\filelist.txt");
|
|
308 |
fname.CreateL(KFileListName);
|
|
309 |
_LIT8(KFileImgName,"c:\\data\\ImgList.txt");
|
|
310 |
iname.CreateL(KFileImgName);
|
|
311 |
_LIT8(KFileMusicName,"c:\\data\\MusicList.txt");
|
|
312 |
mname.CreateL(KFileMusicName);
|
|
313 |
_LIT8(KFileVideoName,"c:\\data\\VideoList.txt");
|
|
314 |
vname.CreateL(KFileVideoName);
|
|
315 |
|
|
316 |
#endif
|
|
317 |
RBuf allfilenames;
|
|
318 |
RBuf photofile;
|
|
319 |
RBuf musicfile;
|
|
320 |
RBuf videofile;
|
|
321 |
|
|
322 |
allfilenames.CreateL(KMaxLength);
|
|
323 |
photofile.CreateL(KMaxLength);
|
|
324 |
musicfile.CreateL(KMaxLength);
|
|
325 |
videofile.CreateL(KMaxLength);
|
|
326 |
|
|
327 |
allfilenames.Copy(fname);
|
|
328 |
photofile.Copy(iname);
|
|
329 |
musicfile.Copy(mname);
|
|
330 |
videofile.Copy(vname);
|
|
331 |
|
|
332 |
CFileParser* parser = CFileParser::NewL();
|
|
333 |
parser->ParseFile(allfilenames,photofile,musicfile,videofile);
|
|
334 |
delete parser;
|
|
335 |
|
|
336 |
allfilenames.Close();
|
|
337 |
photofile.Close();
|
|
338 |
musicfile.Close();
|
|
339 |
videofile.Close();
|
|
340 |
}
|
|
341 |
contactName.Close();
|
|
342 |
|
|
343 |
_LIT8(KPhoto,"c:\\data\\photolist.txt");
|
|
344 |
_LIT8(KMusic,"c:\\data\\musiclist.txt");
|
|
345 |
_LIT8(KVideo,"c:\\data\\videolist.txt");
|
|
346 |
|
|
347 |
////////////////////////////////////////////////////////////////////////////////////
|
|
348 |
//first open the photo file & read it
|
|
349 |
|
|
350 |
ui.treeContactMusic_2->clear();
|
|
351 |
ui.treeContactMusic->clear();
|
|
352 |
ui.treeContactMusic_3->clear();
|
|
353 |
|
|
354 |
QString photofile = QString::fromUtf8((const char*)iname.Ptr(),iname.Length());
|
|
355 |
iGenericFile.setFileName(photofile);
|
|
356 |
iGenericFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
357 |
|
|
358 |
int count = 0;
|
|
359 |
while(!iGenericFile.atEnd())
|
|
360 |
{
|
|
361 |
ReadFile();
|
|
362 |
if(!filename.isEmpty())
|
|
363 |
{
|
|
364 |
new QTreeWidgetItem(ui.treeContactMusic_2);
|
|
365 |
QTreeWidgetItem *qtreewidgetitem = ui.treeContactMusic_2->topLevelItem(count);
|
|
366 |
qtreewidgetitem->setText(0,filename);
|
|
367 |
count++;
|
|
368 |
}
|
|
369 |
}
|
|
370 |
iGenericFile.close();
|
|
371 |
////////////////////////////////////////////////////////////////////////////////////////
|
|
372 |
|
|
373 |
//now open music file & read it
|
|
374 |
QString musicfile = QString::fromUtf8((const char*)mname.Ptr(),mname.Length());
|
|
375 |
iGenericFile.setFileName(musicfile);
|
|
376 |
iGenericFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
377 |
count = 0;
|
|
378 |
while(!iGenericFile.atEnd())
|
|
379 |
{
|
|
380 |
ReadFile();
|
|
381 |
if(!filename.isEmpty())
|
|
382 |
{
|
|
383 |
new QTreeWidgetItem(ui.treeContactMusic);
|
|
384 |
QTreeWidgetItem *qtreewidgetitem = ui.treeContactMusic->topLevelItem(count);
|
|
385 |
qtreewidgetitem->setText(0,filename);
|
|
386 |
count++;
|
|
387 |
}
|
|
388 |
}
|
|
389 |
iGenericFile.close();
|
|
390 |
|
|
391 |
////////////////////////////////////////////////////////////////////////////////////////
|
|
392 |
//now open video file & read it
|
|
393 |
|
|
394 |
QString videofile = QString::fromUtf8((const char*)vname.Ptr(),vname.Length());
|
|
395 |
iGenericFile.setFileName(videofile);
|
|
396 |
iGenericFile.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
397 |
count = 0;
|
|
398 |
while(!iGenericFile.atEnd())
|
|
399 |
{
|
|
400 |
ReadFile();
|
|
401 |
if(!filename.isEmpty())
|
|
402 |
{
|
|
403 |
new QTreeWidgetItem(ui.treeContactMusic_3);
|
|
404 |
QTreeWidgetItem *qtreewidgetitem = ui.treeContactMusic_3->topLevelItem(count);
|
|
405 |
qtreewidgetitem->setText(0,filename);
|
|
406 |
count++;
|
|
407 |
}
|
|
408 |
}
|
|
409 |
iGenericFile.close();
|
|
410 |
////////////////////////////////////////////////////////////////////////////
|
|
411 |
//close all rbufs
|
|
412 |
fname.Close();
|
|
413 |
iname.Close();
|
|
414 |
mname.Close();
|
|
415 |
vname.Close();
|
|
416 |
|
|
417 |
}
|
|
418 |
|
|
419 |
void QZeroConfSharingUi::ReadFile()
|
|
420 |
{
|
|
421 |
qint64 value = Q_INT64_C(255);
|
|
422 |
QByteArray str = iGenericFile.readLine(value);
|
|
423 |
if((!str.isEmpty()) && (str.endsWith('\n')))
|
|
424 |
str.remove((str.length()-1), 1);
|
|
425 |
int index = str.lastIndexOf('/');
|
|
426 |
//cut from the index posn
|
|
427 |
filename = str.mid(index+1);
|
|
428 |
}
|
|
429 |
|
|
430 |
CContactInfo* QZeroConfSharingUi::GetSelectedContact(const TDesC8& aConatactName)
|
|
431 |
{
|
|
432 |
for(TInt i=0;i<iEntries.Count();i++)
|
|
433 |
{
|
|
434 |
if(iEntries[i]->ContactName().Compare(aConatactName)==0)
|
|
435 |
{
|
|
436 |
return iEntries[i];
|
|
437 |
}
|
|
438 |
}
|
|
439 |
return NULL;
|
|
440 |
}
|
|
441 |
|
|
442 |
|
|
443 |
void QZeroConfSharingUi::RequestSharedContent()
|
|
444 |
{
|
|
445 |
|
|
446 |
TPtrC ptrName(reinterpret_cast<const TText*>(iSelectedContact.constData()));
|
|
447 |
RBuf8 contactName;
|
|
448 |
contactName.Create(ptrName.Length());
|
|
449 |
contactName.Copy(ptrName);
|
|
450 |
|
|
451 |
//Find if its an already existing contact
|
|
452 |
CContactInfo* contact = GetSelectedContact(contactName);
|
|
453 |
if(contact!=NULL)
|
|
454 |
{
|
|
455 |
RBuf8 fileUrl;
|
|
456 |
_LIT8(KFileList,"filelist.txt");
|
|
457 |
fileUrl.Create(contact->FileUrl(KFileList));
|
|
458 |
|
|
459 |
iSelectedFileListName = QString::fromUtf8((const char*)(contact->FileListPath(KFileList)).Ptr(),(contact->FileListPath(KFileList)).Length());
|
|
460 |
|
|
461 |
QString qurl = QString::fromUtf8((const char*)(fileUrl).Ptr(),(fileUrl).Length());
|
|
462 |
|
|
463 |
//QMessageBox::warning(this, tr("Icon Path"),qurl,QMessageBox::Ok);
|
|
464 |
|
|
465 |
progressBar = new QProgressDialog(tr("Retrieving Shared Content"), tr("Cancel"), 0, 0);
|
|
466 |
connect(progressBar, SIGNAL(canceled()), this, SLOT(ProgressBarCanceled()));
|
|
467 |
progressBar->show();
|
|
468 |
|
|
469 |
#ifdef __arm
|
|
470 |
reply = manager->get(QNetworkRequest(QUrl(qurl)));
|
|
471 |
#else
|
|
472 |
reply = manager->get(QNetworkRequest(QUrl("http://kiranp747.googlepages.com/FileList.txt")));
|
|
473 |
#endif
|
|
474 |
|
|
475 |
connect(reply, SIGNAL(finished()), this, SLOT(RequestFinished()));
|
|
476 |
|
|
477 |
fileUrl.Close();
|
|
478 |
}
|
|
479 |
contactName.Close();
|
|
480 |
|
|
481 |
}
|
|
482 |
void QZeroConfSharingUi::on_listAvatars_itemClicked(QListWidgetItem* item)
|
|
483 |
{
|
|
484 |
|
|
485 |
if(progressBar != NULL)
|
|
486 |
return;
|
|
487 |
|
|
488 |
iSelectedContact = item->text();
|
|
489 |
|
|
490 |
setWindowTitle(iSelectedContact);
|
|
491 |
ui.tabWidget->removeTab(0);
|
|
492 |
ui.tabWidget->insertTab(0, ui.tabVivek, QIcon(":/Images/Unknown"), "Wall");
|
|
493 |
ui.tabWidget->insertTab(4, ui.tabChat, QIcon(":/Icons/Chat"), "Chat");
|
|
494 |
ui.tabWidget->setCurrentIndex(0);
|
|
495 |
|
|
496 |
ShowBackButtons(true);
|
|
497 |
|
|
498 |
ui.treeContactMusic->setVisible(true);
|
|
499 |
ui.treeContactMusic_2->setVisible(true);
|
|
500 |
ui.treeContactMusic_3->setVisible(true);
|
|
501 |
|
|
502 |
ui.treeMusicAll_3->setVisible(false);
|
|
503 |
ui.treeMusicAll->setVisible(false);
|
|
504 |
ui.treeMusicAll_2->setVisible(false);
|
|
505 |
#ifndef __arm
|
|
506 |
PopulateContactSpecificData();
|
|
507 |
#endif
|
|
508 |
|
|
509 |
RequestSharedContent();
|
|
510 |
ShowCur_Status_and_Track();
|
|
511 |
|
|
512 |
}
|
|
513 |
|
|
514 |
void QZeroConfSharingUi::ProgressBarCanceled()
|
|
515 |
{
|
|
516 |
//if(progressBar && progressBar->isVisible())
|
|
517 |
if(progressBar)
|
|
518 |
{
|
|
519 |
//progressBar->close();
|
|
520 |
delete progressBar;
|
|
521 |
progressBar = NULL;
|
|
522 |
}
|
|
523 |
}
|
|
524 |
|
|
525 |
void QZeroConfSharingUi::ItemRequestFinished()
|
|
526 |
{
|
|
527 |
if(progressBar && progressBar->isVisible())
|
|
528 |
{
|
|
529 |
progressBar->close();
|
|
530 |
delete progressBar;
|
|
531 |
progressBar = NULL;
|
|
532 |
}
|
|
533 |
|
|
534 |
int error = itemReply->error();
|
|
535 |
if(!error)
|
|
536 |
{
|
|
537 |
QNetworkReply *reply = ((QNetworkReply *)sender());
|
|
538 |
QByteArray data = reply->readAll();
|
|
539 |
|
|
540 |
if(data.isEmpty())
|
|
541 |
QMessageBox::warning(this, tr("Test"),tr("No Data Reply"),QMessageBox::Ok);
|
|
542 |
|
|
543 |
QFile temp(iSelectedFileName);
|
|
544 |
temp.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
|
545 |
temp.write(data);
|
|
546 |
temp.close();
|
|
547 |
|
|
548 |
QUrl itemUrl(iSelectedFileName);
|
|
549 |
|
|
550 |
bool ret = QDesktopServices::openUrl(itemUrl);
|
|
551 |
if(!ret)
|
|
552 |
QMessageBox::warning( this, tr("Operation Failed"), tr("Unkown error!"), QMessageBox::Close);
|
|
553 |
|
|
554 |
}
|
|
555 |
else
|
|
556 |
QMessageBox::warning(this, tr("Test"),reply->errorString(),QMessageBox::Ok);
|
|
557 |
|
|
558 |
|
|
559 |
|
|
560 |
}
|
|
561 |
|
|
562 |
void QZeroConfSharingUi::RequestFinished()
|
|
563 |
{
|
|
564 |
|
|
565 |
if(progressBar && progressBar->isVisible())
|
|
566 |
{
|
|
567 |
progressBar->close();
|
|
568 |
delete progressBar;
|
|
569 |
progressBar = NULL;
|
|
570 |
}
|
|
571 |
|
|
572 |
int error = reply->error();
|
|
573 |
if(!error)
|
|
574 |
{
|
|
575 |
QNetworkReply *reply = ((QNetworkReply *)sender());
|
|
576 |
QByteArray data = reply->readAll();
|
|
577 |
|
|
578 |
if(data.isEmpty())
|
|
579 |
QMessageBox::warning(this, tr("Test"),tr("No Data Reply"),QMessageBox::Ok);
|
|
580 |
|
|
581 |
QFile temp(iSelectedFileListName);
|
|
582 |
temp.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
|
583 |
temp.write(data);
|
|
584 |
temp.close();
|
|
585 |
|
|
586 |
PopulateContactSpecificData();
|
|
587 |
//}
|
|
588 |
}
|
|
589 |
else
|
|
590 |
QMessageBox::warning(this, tr("Test"),reply->errorString(),QMessageBox::Ok);
|
|
591 |
|
|
592 |
|
|
593 |
}
|
|
594 |
|
|
595 |
void QZeroConfSharingUi::ShowCur_Status_and_Track()
|
|
596 |
{
|
|
597 |
|
|
598 |
TPtrC ptrName(reinterpret_cast<const TText*>(iSelectedContact.constData()));
|
|
599 |
|
|
600 |
RBuf8 contactName;
|
|
601 |
RBuf8 currentTrack,currentUserStatus;
|
|
602 |
|
|
603 |
contactName.Create(ptrName.Length());
|
|
604 |
contactName.Copy(ptrName);
|
|
605 |
|
|
606 |
//get complete contact info of the person
|
|
607 |
|
|
608 |
for(TInt i=0;i<iEntries.Count();i++)
|
|
609 |
{
|
|
610 |
if(iEntries[i]->ContactName().Compare(contactName)==0)
|
|
611 |
{
|
|
612 |
currentTrack.CreateL(iEntries[i]->CurrentlyPlaying().Length());
|
|
613 |
currentTrack.Copy(iEntries[i]->CurrentlyPlaying());
|
|
614 |
|
|
615 |
currentUserStatus.CreateL(iEntries[i]->Status().Length());
|
|
616 |
currentUserStatus.Copy(iEntries[i]->Status());
|
|
617 |
|
|
618 |
ui.textEdit_2->clear ();
|
|
619 |
QString nowPlayingLabel = "Now Playing: ";
|
|
620 |
QString nowPlayingTrack = QString::fromUtf8((const char*)currentTrack.Ptr(),currentTrack.Length());
|
|
621 |
QString total(nowPlayingLabel);
|
|
622 |
total.append(nowPlayingTrack);
|
|
623 |
|
|
624 |
QString newline(tr("\n\n\n"));
|
|
625 |
total.append(newline);
|
|
626 |
QString nowStatusLabel = "Status: ";
|
|
627 |
total.append(nowStatusLabel);
|
|
628 |
QString nowStatusString = QString::fromUtf8((const char*)currentUserStatus.Ptr(),currentUserStatus.Length());
|
|
629 |
total.append(nowStatusString);
|
|
630 |
|
|
631 |
|
|
632 |
ui.textEdit_2->setText(total);
|
|
633 |
}
|
|
634 |
}
|
|
635 |
currentTrack.Close();
|
|
636 |
currentUserStatus.Close();
|
|
637 |
contactName.Close();
|
|
638 |
|
|
639 |
|
|
640 |
}//end of function
|
|
641 |
|
|
642 |
|
|
643 |
void QZeroConfSharingUi::ShowAllContacts(bool aShow)
|
|
644 |
{
|
|
645 |
if(aShow)
|
|
646 |
{
|
|
647 |
// Contact Tab
|
|
648 |
ui.tabWidget->removeTab(0);
|
|
649 |
// Add All Contacts tab
|
|
650 |
ui.tabWidget->insertTab(0, ui.tabContacts, QIcon(":/Icons/Contact"), "Contacts");
|
|
651 |
// Chat Tab
|
|
652 |
ui.tabWidget->removeTab(4);
|
|
653 |
// Set Focus
|
|
654 |
ui.tabWidget->setCurrentIndex(0);
|
|
655 |
}
|
|
656 |
else
|
|
657 |
{
|
|
658 |
ui.tabWidget->removeTab(0);
|
|
659 |
//ui.tabWidget->insertTab(0, ui.tabVivek, QIcon(":/Images/Vivek"), "Vivek's Wall");
|
|
660 |
ui.tabWidget->insertTab(4, ui.tabChat, QIcon(":/Icons/Chat"), "Chat");
|
|
661 |
ui.tabWidget->setCurrentIndex(0);
|
|
662 |
}
|
|
663 |
// Music
|
|
664 |
//ui.textMusicAll->setVisible(aShow);
|
|
665 |
//ui.treeMusicAll->setVisible(aShow);
|
|
666 |
//ui.treeContactMusic->setVisible(!aShow);
|
|
667 |
|
|
668 |
ShowBackButtons(!aShow);
|
|
669 |
}
|
|
670 |
|
|
671 |
void QZeroConfSharingUi::ShowBackButtons(bool aShow)
|
|
672 |
{
|
|
673 |
|
|
674 |
// Push Buttons
|
|
675 |
ui.pushBackChat->setVisible(aShow);
|
|
676 |
ui.pushBackContact->setVisible(aShow);
|
|
677 |
ui.pushBackPhoto->setVisible(aShow);
|
|
678 |
ui.pushBackMusic->setVisible(aShow);
|
|
679 |
ui.pushBackVideo->setVisible(aShow);
|
|
680 |
|
|
681 |
|
|
682 |
}
|
|
683 |
|
|
684 |
void QZeroConfSharingUi::on_pushBackContact_clicked()
|
|
685 |
{
|
|
686 |
ShowAllContacts(true);
|
|
687 |
}
|
|
688 |
|
|
689 |
void QZeroConfSharingUi::on_pushBackMusic_clicked()
|
|
690 |
{
|
|
691 |
ShowAllContacts(true);
|
|
692 |
}
|
|
693 |
|
|
694 |
void QZeroConfSharingUi::on_pushBackVideo_clicked()
|
|
695 |
{
|
|
696 |
ShowAllContacts(true);
|
|
697 |
}
|
|
698 |
|
|
699 |
void QZeroConfSharingUi::on_pushBackChat_clicked()
|
|
700 |
{
|
|
701 |
ShowAllContacts(true);
|
|
702 |
}
|
|
703 |
|
|
704 |
void QZeroConfSharingUi::on_pushBackFile_clicked()
|
|
705 |
{
|
|
706 |
ShowAllContacts(true);
|
|
707 |
}
|
|
708 |
|
|
709 |
|
|
710 |
void QZeroConfSharingUi::StartServer()
|
|
711 |
{
|
|
712 |
menuBar()->removeAction(shareAction);
|
|
713 |
menuBar()->addAction(unshareAction);
|
|
714 |
|
|
715 |
iHttpServer = CHttpServer::NewL();
|
|
716 |
|
|
717 |
iHttpServer->ProcessSelectionL(EStart);
|
|
718 |
|
|
719 |
CFileListEngine* filelister = CFileListEngine::NewL();
|
|
720 |
filelister->SetOutputFileName(_L("c:\\data\\Images\\filelist.txt"));
|
|
721 |
filelister->GetAllMediaContent();
|
|
722 |
delete filelister;
|
|
723 |
|
|
724 |
_LIT8(Kfilelist,"filelist.txt");
|
|
725 |
_LIT8(KIconName,"mypic.ico");
|
|
726 |
iPublishBaseUrl.Create(KMaxPath);
|
|
727 |
iPublishBaseUrl.Copy(_L8("http://"));
|
|
728 |
iPublishBaseUrl.Append(iHttpServer->GetIPAddress());
|
|
729 |
iPublishBaseUrl.Append(_L8("/Images/")); //http://<ipaddr>/
|
|
730 |
|
|
731 |
PublishMyService(Kfilelist,KIconName);
|
|
732 |
|
|
733 |
}
|
|
734 |
|
|
735 |
|
|
736 |
void QZeroConfSharingUi::StopServer()
|
|
737 |
{
|
|
738 |
//ToDo: Should stop server and unpublish the services.
|
|
739 |
|
|
740 |
menuBar()->removeAction(unshareAction);
|
|
741 |
menuBar()->addAction(shareAction);
|
|
742 |
|
|
743 |
iZeroConfClient->UnPublishServices();
|
|
744 |
iHttpServer->ProcessSelectionL(EStop);
|
|
745 |
delete iHttpServer;
|
|
746 |
|
|
747 |
}
|
|
748 |
|
|
749 |
void QZeroConfSharingUi::NowPlaying(TDes& aTitleBuf)
|
|
750 |
{
|
|
751 |
//QString qtTitle = QString::fromUtf16(aTitleBuf.Ptr(),aTitleBuf.Length());
|
|
752 |
//QMessageBox::warning(this,tr("Now playing"),qtTitle,QMessageBox::Ok);
|
|
753 |
if(iUpdate)
|
|
754 |
{
|
|
755 |
iZeroConfClient->UpdateNowPlayingServiceL(aTitleBuf);
|
|
756 |
}
|
|
757 |
else
|
|
758 |
{
|
|
759 |
iZeroConfClient->PublishNowPlayingServiceL(aTitleBuf);
|
|
760 |
iUpdate = ETrue;
|
|
761 |
}
|
|
762 |
}
|
|
763 |
|
|
764 |
void QZeroConfSharingUi::DiscoverServices()
|
|
765 |
{
|
|
766 |
|
|
767 |
iZeroConfClient->WriteServices();
|
|
768 |
}
|
|
769 |
|
|
770 |
void QZeroConfSharingUi::GetSrvInfo(const TDesC8& aQueryString,TDnsType aType)
|
|
771 |
{
|
|
772 |
iZeroConfClient->GetService(aQueryString,aType);
|
|
773 |
}
|
|
774 |
|
|
775 |
void QZeroConfSharingUi::PublishService()
|
|
776 |
{
|
|
777 |
iZeroConfClient->PublishService();
|
|
778 |
}
|
|
779 |
|
|
780 |
void QZeroConfSharingUi:: PublishMyService(const TDesC8& afilelist,const TDesC8& aIconName)
|
|
781 |
{
|
|
782 |
iZeroConfClient->PublishMyService(iPublishBaseUrl, afilelist, aIconName);
|
|
783 |
}
|
|
784 |
|
|
785 |
QZeroConfSharingUi::~QZeroConfSharingUi()
|
|
786 |
{
|
|
787 |
iPublishBaseUrl.Close();
|
|
788 |
|
|
789 |
iBaseUrl.Close();
|
|
790 |
iIconName.Close();
|
|
791 |
iFileName.Close();
|
|
792 |
iCurrentlyPlaying.Close();
|
|
793 |
iStatus.Close();
|
|
794 |
iContactName.Close();
|
|
795 |
MyStatusFile.close();
|
|
796 |
|
|
797 |
for(TInt i=0;i<iEntries.Count();i++)
|
|
798 |
{
|
|
799 |
delete iEntries[i];
|
|
800 |
}
|
|
801 |
|
|
802 |
iEntries.Reset();
|
|
803 |
delete iNewContact;
|
|
804 |
delete iNewContact;
|
|
805 |
if(manager)
|
|
806 |
{
|
|
807 |
manager->disconnect();
|
|
808 |
delete manager;
|
|
809 |
manager = 0;
|
|
810 |
}
|
|
811 |
}
|
|
812 |
|
|
813 |
void QZeroConfSharingUi::PopulateMainWindow(QString qname)
|
|
814 |
{
|
|
815 |
QTreeWidgetItem *qtreewidgetitem1 = new QTreeWidgetItem(ui.treeMusicAll_3);
|
|
816 |
qtreewidgetitem1->setText(0,qname);
|
|
817 |
ui.treeMusicAll_3->addTopLevelItem(qtreewidgetitem1);
|
|
818 |
|
|
819 |
QTreeWidgetItem *qtreewidgetitem2 = new QTreeWidgetItem(ui.treeMusicAll);
|
|
820 |
qtreewidgetitem2->setText(0,qname);
|
|
821 |
ui.treeMusicAll->addTopLevelItem(qtreewidgetitem2);
|
|
822 |
|
|
823 |
QTreeWidgetItem *qtreewidgetitem3 = new QTreeWidgetItem(ui.treeMusicAll_2);
|
|
824 |
qtreewidgetitem3->setText(0,qname);
|
|
825 |
ui.treeMusicAll_2->addTopLevelItem(qtreewidgetitem3);
|
|
826 |
}
|
|
827 |
void QZeroConfSharingUi::OnPnPEventL (RPnPParameterBundleBase& aServiceEventInfo)
|
|
828 |
{
|
|
829 |
//isPresent =EFalse;
|
|
830 |
Log("ZeroConfSharingUi::OnPnPEventL - Entry\n");
|
|
831 |
RBuf8 ptrInfo;
|
|
832 |
aServiceEventInfo.Store(ptrInfo);
|
|
833 |
CContactInfo* contactInfo = NULL;
|
|
834 |
TInt familyCount = aServiceEventInfo.CountParameterFamilies();
|
|
835 |
for(TInt idx=0; idx<aServiceEventInfo.CountParameterFamilies();idx++)
|
|
836 |
{
|
|
837 |
RParameterFamily pnpFamily = aServiceEventInfo.GetFamilyAtIndex(idx);
|
|
838 |
switch(pnpFamily.Id())
|
|
839 |
{
|
|
840 |
case EMdnsPtrParamset:
|
|
841 |
{
|
|
842 |
TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
|
|
843 |
for (TInt index= 0; index < count ; index++ )
|
|
844 |
{
|
|
845 |
CMDnsPtrParamSet* ptrParamSet = static_cast<CMDnsPtrParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
|
|
846 |
RBuf name;
|
|
847 |
RBuf domain;
|
|
848 |
name.CreateL(255);
|
|
849 |
domain.CreateL(255);
|
|
850 |
name.Copy(ptrParamSet->InstanceName());
|
|
851 |
domain.Copy(ptrParamSet->DomainName());
|
|
852 |
|
|
853 |
_LIT(KServicesDns,"_services._dns-sd._udp.local.");
|
|
854 |
if(name.Compare(KServicesDns)!=0)
|
|
855 |
{
|
|
856 |
TChar ch = '.';
|
|
857 |
TInt pos = domain.Locate(ch);
|
|
858 |
|
|
859 |
if(pos != KErrNotFound)
|
|
860 |
{
|
|
861 |
RBuf buf16;
|
|
862 |
buf16.CreateL(domain.Mid(0,pos));
|
|
863 |
iSrvName.Close();
|
|
864 |
iSrvName.CreateL(buf16.Length());
|
|
865 |
iSrvName.Copy(buf16.Collapse());
|
|
866 |
//Dont query if you have got all records at a shot!!
|
|
867 |
if(aServiceEventInfo.CountParameterFamilies() <= 1)
|
|
868 |
{
|
|
869 |
Log("ZeroConfSharingUi::OnPnPEventL - Query for SRV\n");
|
|
870 |
QString tempname5 = QString::fromUtf8((const char*)iSrvName.Ptr(),iSrvName.Length());
|
|
871 |
|
|
872 |
logFile.open(QIODevice::Append);
|
|
873 |
logFile.write(tempname5.toUtf8());
|
|
874 |
logFile.close();
|
|
875 |
|
|
876 |
GetSrvInfo(iSrvName,EDnsQType_Any);
|
|
877 |
}
|
|
878 |
buf16.Close();
|
|
879 |
}
|
|
880 |
}
|
|
881 |
|
|
882 |
name.Close();
|
|
883 |
domain.Close();
|
|
884 |
}
|
|
885 |
}
|
|
886 |
break;
|
|
887 |
|
|
888 |
case EMdnsSrvParamset:
|
|
889 |
{
|
|
890 |
TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
|
|
891 |
for (TInt index= 0; index < count ; index++ )
|
|
892 |
{
|
|
893 |
TBool isPresent = EFalse;
|
|
894 |
CMDnsSrvParamSet* srvParamSet = static_cast<CMDnsSrvParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
|
|
895 |
RBuf name;
|
|
896 |
RBuf target;
|
|
897 |
name.CreateL(255);
|
|
898 |
target.CreateL(255);
|
|
899 |
target.Copy(srvParamSet->Target());
|
|
900 |
name.Copy(srvParamSet->DomainName());
|
|
901 |
|
|
902 |
Log("ZeroConfSharingUi::OnPnPEventL - Print srv inst name\n\t");
|
|
903 |
QString tempname1 = QString::fromUtf16(name.Ptr(),name.Length());
|
|
904 |
|
|
905 |
logFile.open(QIODevice::Append);
|
|
906 |
logFile.write(tempname1.toAscii());
|
|
907 |
logFile.close();
|
|
908 |
|
|
909 |
Log("ZeroConfSharingUi::OnPnPEventL - Print target\n\t");
|
|
910 |
QString tempname2 = QString::fromUtf16(target.Ptr(),target.Length());
|
|
911 |
|
|
912 |
logFile.open(QIODevice::Append);
|
|
913 |
logFile.write(tempname2.toAscii());
|
|
914 |
logFile.close();
|
|
915 |
TChar ch = '.';
|
|
916 |
TInt pos = target.Locate(ch);
|
|
917 |
|
|
918 |
RBuf targetName;
|
|
919 |
targetName.CreateL(target.Mid(0,pos));
|
|
920 |
|
|
921 |
if(iContactName.Length()!=0)
|
|
922 |
{
|
|
923 |
iContactName.Close();
|
|
924 |
}
|
|
925 |
iContactName.Create(targetName.Length());
|
|
926 |
iContactName.Copy(targetName);
|
|
927 |
|
|
928 |
for(TInt i=0;i<iEntries.Count();i++)
|
|
929 |
{
|
|
930 |
if(iEntries[i]->ContactName().Compare(iContactName)==0)
|
|
931 |
{
|
|
932 |
Log("ZeroConfSharingUi::OnPnPEventL - Contact Exists\n\t");
|
|
933 |
|
|
934 |
QString tempname = QString::fromUtf8((const char*)iContactName.Ptr(),iContactName.Length());
|
|
935 |
|
|
936 |
logFile.open(QIODevice::Append);
|
|
937 |
logFile.write(tempname.toUtf8());
|
|
938 |
logFile.close();
|
|
939 |
|
|
940 |
isPresent = ETrue;
|
|
941 |
break;
|
|
942 |
}
|
|
943 |
}
|
|
944 |
if(!isPresent)
|
|
945 |
{
|
|
946 |
Log("ZeroConfSharingUi::OnPnPEventL - New Contact Added\n");
|
|
947 |
contactInfo = Create_Icon_Contact();
|
|
948 |
}
|
|
949 |
/*
|
|
950 |
if(aServiceEventInfo.CountParameterFamilies() <= 1)
|
|
951 |
{
|
|
952 |
GetSrvInfo(iSrvName,EDnsQType_Any);
|
|
953 |
}
|
|
954 |
*/
|
|
955 |
name.Close();
|
|
956 |
target.Close();
|
|
957 |
targetName.Close();
|
|
958 |
|
|
959 |
}
|
|
960 |
|
|
961 |
|
|
962 |
}
|
|
963 |
break;
|
|
964 |
|
|
965 |
case EMdnsTxtParamset:
|
|
966 |
{
|
|
967 |
TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
|
|
968 |
for (TInt index= 0; index < count ; index++ )
|
|
969 |
{
|
|
970 |
CMDnsTxtParamSet* txtParamSet = static_cast<CMDnsTxtParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
|
|
971 |
|
|
972 |
RArray <RBuf8> txtData ;
|
|
973 |
txtParamSet->TxtDataL(txtData);
|
|
974 |
|
|
975 |
|
|
976 |
if(contactInfo != NULL)
|
|
977 |
{
|
|
978 |
FetchBaseUrl(txtData);
|
|
979 |
FetchIconUrl(txtData);
|
|
980 |
FetchFileUrl(txtData);
|
|
981 |
|
|
982 |
|
|
983 |
contactInfo->SetBaseUrl(iBaseUrl);
|
|
984 |
FetchCurrentlyPlaying(txtData);
|
|
985 |
FetchStatus(txtData);
|
|
986 |
//See if we have got the Currently Played song
|
|
987 |
if(iCurrentlyPlaying.Length()!=0)
|
|
988 |
{
|
|
989 |
contactInfo->SetCurrentlyPlaying(iCurrentlyPlaying);
|
|
990 |
|
|
991 |
|
|
992 |
}
|
|
993 |
else if (iStatus.Length()!=0)
|
|
994 |
{
|
|
995 |
contactInfo->SetStatus(iStatus);
|
|
996 |
|
|
997 |
}
|
|
998 |
iEntries.Append(Clone(contactInfo));
|
|
999 |
}
|
|
1000 |
else
|
|
1001 |
{
|
|
1002 |
FetchCurrentlyPlaying(txtData);
|
|
1003 |
FetchStatus(txtData);
|
|
1004 |
CContactInfo** contact = NULL;
|
|
1005 |
|
|
1006 |
for(TInt i=0;i<iEntries.Count();i++)
|
|
1007 |
{
|
|
1008 |
if(iEntries[i]->ContactName().Compare(iContactName)==0)
|
|
1009 |
{
|
|
1010 |
if(iCurrentlyPlaying.Length()!=0)
|
|
1011 |
iEntries[i]->SetCurrentlyPlaying(iCurrentlyPlaying);
|
|
1012 |
else if(iStatus.Length()!=0)
|
|
1013 |
iEntries[i]->SetStatus(iStatus);
|
|
1014 |
|
|
1015 |
TPtrC ptrName(reinterpret_cast<const TText*>(iSelectedContact.constData()));
|
|
1016 |
RBuf8 tempcontact;
|
|
1017 |
tempcontact.Create(ptrName.Length());
|
|
1018 |
tempcontact.Copy(ptrName);
|
|
1019 |
if(iEntries[i]->ContactName().Compare(tempcontact)== 0)
|
|
1020 |
{
|
|
1021 |
ShowCur_Status_and_Track();
|
|
1022 |
}
|
|
1023 |
tempcontact.Close();
|
|
1024 |
}
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
}
|
|
1028 |
|
|
1029 |
}
|
|
1030 |
}
|
|
1031 |
break;
|
|
1032 |
|
|
1033 |
case EMdnsPublishResponseParamset:
|
|
1034 |
{
|
|
1035 |
TUint count = pnpFamily.CountParameterSets ( RParameterFamily::ERequested ) ;
|
|
1036 |
for (TInt index= 0; index < count ; index++ )
|
|
1037 |
{
|
|
1038 |
CMDnsPublishResponseParamSet* publishRespParam = static_cast<CMDnsPublishResponseParamSet*>(pnpFamily.GetParameterSetAtIndex( index, RParameterFamily::ERequested ));
|
|
1039 |
RBuf name;
|
|
1040 |
name.CreateL(255);
|
|
1041 |
name.Copy(publishRespParam->DomainName());
|
|
1042 |
_LIT(KCRLF, "\r\n A service was published with the name: \n");
|
|
1043 |
RBuf str;
|
|
1044 |
str.CreateL(255);
|
|
1045 |
str.Copy(KCRLF);
|
|
1046 |
name.Close();
|
|
1047 |
str.Close();
|
|
1048 |
}
|
|
1049 |
}
|
|
1050 |
break;
|
|
1051 |
}
|
|
1052 |
}
|
|
1053 |
ptrInfo.Close();
|
|
1054 |
Log("ZeroConfSharingUi::OnPnPEventL - Exit\n");
|
|
1055 |
}
|
|
1056 |
|
|
1057 |
void QZeroConfSharingUi::OnPnPError (TInt /*aError*/)
|
|
1058 |
{
|
|
1059 |
|
|
1060 |
}
|
|
1061 |
|
|
1062 |
|
|
1063 |
void QZeroConfSharingUi::FetchBaseUrl(RArray <RBuf8> aTxtData)
|
|
1064 |
{
|
|
1065 |
iBaseUrl.Close();
|
|
1066 |
|
|
1067 |
_LIT8(KBaseUrl,"BaseUrl");
|
|
1068 |
TChar ch = '=';
|
|
1069 |
RBuf8 key;
|
|
1070 |
for(TInt index=0;index<aTxtData.Count();index++)
|
|
1071 |
{
|
|
1072 |
TInt position = aTxtData[index].Locate(ch);
|
|
1073 |
if(position!= KErrNotFound)
|
|
1074 |
{
|
|
1075 |
key.Close();
|
|
1076 |
key.CreateL(aTxtData[index].Mid(0,(position-1)));
|
|
1077 |
if(key.Compare(KBaseUrl)==0)
|
|
1078 |
{
|
|
1079 |
iBaseUrl.CreateL(aTxtData[index].Mid((position+2)));
|
|
1080 |
break;
|
|
1081 |
}
|
|
1082 |
}
|
|
1083 |
}
|
|
1084 |
key.Close();
|
|
1085 |
}
|
|
1086 |
|
|
1087 |
void QZeroConfSharingUi::FetchIconUrl(RArray <RBuf8> aTxtData)
|
|
1088 |
{
|
|
1089 |
iIconName.Close();
|
|
1090 |
|
|
1091 |
_LIT8(KIconUrl,"IconUrl");
|
|
1092 |
TChar ch = '=';
|
|
1093 |
RBuf8 key;
|
|
1094 |
for(TInt index=0;index<aTxtData.Count();index++)
|
|
1095 |
{
|
|
1096 |
TInt position = aTxtData[index].Locate(ch);
|
|
1097 |
if(position!= KErrNotFound)
|
|
1098 |
{
|
|
1099 |
key.Close();
|
|
1100 |
key.CreateL(aTxtData[index].Mid(0,(position-1)));
|
|
1101 |
if(key.Compare(KIconUrl)==0)
|
|
1102 |
{
|
|
1103 |
iIconName.CreateL(aTxtData[index].Mid((position+2)));
|
|
1104 |
break;
|
|
1105 |
}
|
|
1106 |
}
|
|
1107 |
}
|
|
1108 |
key.Close();
|
|
1109 |
}
|
|
1110 |
|
|
1111 |
void QZeroConfSharingUi::FetchFileUrl(RArray <RBuf8> aTxtData)
|
|
1112 |
{
|
|
1113 |
iFileName.Close();
|
|
1114 |
|
|
1115 |
_LIT8(KFileUrl,"FileUrl");
|
|
1116 |
TChar ch = '=';
|
|
1117 |
RBuf8 key;
|
|
1118 |
for(TInt index=0;index<aTxtData.Count();index++)
|
|
1119 |
{
|
|
1120 |
TInt position = aTxtData[index].Locate(ch);
|
|
1121 |
if(position!= KErrNotFound)
|
|
1122 |
{
|
|
1123 |
key.Close();
|
|
1124 |
key.CreateL(aTxtData[index].Mid(0,(position-1)));
|
|
1125 |
if(key.Compare(KFileUrl)==0)
|
|
1126 |
{
|
|
1127 |
iFileName.CreateL(aTxtData[index].Mid((position+2)));
|
|
1128 |
break;
|
|
1129 |
}
|
|
1130 |
}
|
|
1131 |
}
|
|
1132 |
key.Close();
|
|
1133 |
}
|
|
1134 |
|
|
1135 |
void QZeroConfSharingUi::FetchCurrentlyPlaying(RArray <RBuf8> aTxtData)
|
|
1136 |
{
|
|
1137 |
iCurrentlyPlaying.Close();
|
|
1138 |
|
|
1139 |
_LIT8(KNowPlaying,"Now playing");
|
|
1140 |
TChar ch = '=';
|
|
1141 |
RBuf8 key;
|
|
1142 |
TInt cnt = aTxtData.Count();
|
|
1143 |
for(TInt index=0;index<aTxtData.Count();index++)
|
|
1144 |
{
|
|
1145 |
TInt position = aTxtData[index].Locate(ch);
|
|
1146 |
if(position!= KErrNotFound)
|
|
1147 |
{
|
|
1148 |
key.Close();
|
|
1149 |
key.CreateL(aTxtData[index].Mid(0,(position-1)));
|
|
1150 |
if(key.Compare(KNowPlaying)==0)
|
|
1151 |
{
|
|
1152 |
iCurrentlyPlaying.CreateL(aTxtData[index].Mid((position+2)));
|
|
1153 |
break;
|
|
1154 |
}
|
|
1155 |
}
|
|
1156 |
}
|
|
1157 |
key.Close();
|
|
1158 |
}
|
|
1159 |
|
|
1160 |
void QZeroConfSharingUi::FetchStatus(RArray <RBuf8> aTxtData)
|
|
1161 |
{
|
|
1162 |
iStatus.Close();
|
|
1163 |
|
|
1164 |
_LIT8(KStatus,"Status");
|
|
1165 |
TChar ch = '=';
|
|
1166 |
RBuf8 key;
|
|
1167 |
for(TInt index=0;index<aTxtData.Count();index++)
|
|
1168 |
{
|
|
1169 |
TInt position = aTxtData[index].Locate(ch);
|
|
1170 |
if(position!= KErrNotFound)
|
|
1171 |
{
|
|
1172 |
key.Close();
|
|
1173 |
key.CreateL(aTxtData[index].Mid(0,(position-1)));
|
|
1174 |
if(key.Compare(KStatus)==0)
|
|
1175 |
{
|
|
1176 |
iStatus.CreateL(aTxtData[index].Mid((position+2)));
|
|
1177 |
break;
|
|
1178 |
}
|
|
1179 |
}
|
|
1180 |
}
|
|
1181 |
key.Close();
|
|
1182 |
}
|
|
1183 |
|
|
1184 |
|
|
1185 |
CContactInfo* QZeroConfSharingUi::Clone(CContactInfo* aContact)
|
|
1186 |
{
|
|
1187 |
//Clone the entry and insert in Hash
|
|
1188 |
CContactInfo* contact = CContactInfo::NewL();
|
|
1189 |
contact->SetBaseUrl(aContact->BaseUrl());
|
|
1190 |
contact->StoreContactDirectory(aContact->ContactDirectory());
|
|
1191 |
contact->SetContactName(aContact->ContactName());
|
|
1192 |
contact->SetCurrentlyPlaying(aContact->CurrentlyPlaying());
|
|
1193 |
contact->SetStatus(aContact->Status());
|
|
1194 |
|
|
1195 |
return contact;
|
|
1196 |
|
|
1197 |
//iContactEntries.Insert(contact->ContactName(),contact);
|
|
1198 |
}
|
|
1199 |
|
|
1200 |
CContactInfo* QZeroConfSharingUi::Create_Icon_Contact()
|
|
1201 |
{
|
|
1202 |
CContactInfo* contact = NULL;
|
|
1203 |
QString qtName = QString::fromUtf8((const char*)iContactName.Ptr(),iContactName.Length());
|
|
1204 |
QString path(":/Icons/user");
|
|
1205 |
QListWidgetItem* item = new QListWidgetItem(QIcon(":/Images/Unknown"),qtName );
|
|
1206 |
ui.listAvatars->addItem(item);
|
|
1207 |
|
|
1208 |
PopulateMainWindow(qtName);
|
|
1209 |
|
|
1210 |
//Create a new contact
|
|
1211 |
contact = CContactInfo::NewL();
|
|
1212 |
contact->SetContactName(iContactName);
|
|
1213 |
//Creates the contact specific directory
|
|
1214 |
contact->SetContactDirectory();
|
|
1215 |
|
|
1216 |
return contact;
|
|
1217 |
|
|
1218 |
}
|