View
221
Download
0
Category
Preview:
Citation preview
8/3/2019 Report Ghini Project
1/23
Project Reportby
Gino Cappelli
Prof: Vittorio Ghini
University of Bologna
A.Y. 2010/2011
1
8/3/2019 Report Ghini Project
2/23
Table of contents
1. Introduction 3
2. Set-up of the environment 5
3. Added features 7
4. Modularity and Portability 20
5. Future development 22
2
8/3/2019 Report Ghini Project
3/23
1. Introduction
In the following report are explained some important points ofthe project on which I have worked during the third year of my
Degree at University of Bologna.
The main project objective has been to add some features to an
existing application calledJangiu[1]. The application is a cross-
platform VoIPClient for smart-phones with a friendly user interface[2]. This application has been mainly developed for the Symbian
O.S. [3] (in C++) using the Qtlibraries [4] for the design of theGUI. My scope of interests regarded the user-interface (graphic)
side, moving the important part of my project to the Qt modules of
the application (and not to the low-level modules containing the
implementation of the SIPprotocol [5]). In facts, I developed twomain features:
A search functionality (of the contacts), based on a prefix
inserted in a search bar The division of the contacts using groups
In the next chapter are described many troubles that I have had
during the set-up of the CarbideC++ environment [6].
In the chapters 3 and 4 it is explained how the above features
have been added and the repercussion of these modules on theapplication portability.
Finally, the chapter 5 suggests some possible future
development plans for this application.
3
8/3/2019 Report Ghini Project
4/23
Figure 1: An image of the Jangiu application running
on the Symbian emulator[7]
4
8/3/2019 Report Ghini Project
5/23
2. Set-up of the environment
TheJangiu application has been developed using the CarbideC++ IDE (v 2.7) that provides many useful features for the Symbian
developers. In [1] is explained how to correctly perform all the
steps necessary to set-up the IDE with the application and all its
libraries (Qt,PjSIP(Open Source SIP Stack) [8] ).
Once obtained the source code of the Jangiu application (see
[1]), and correctly imported the project in the IDE ([1]), it will be
possible to carry out the following steps to solve many problemsconcerning the correct behavior of the application:
Commentthe line 995 in thesock_common.c file (under
pjproject [see 1], pjlib/src/pj/sock_common.c)
len = sizeof(a);status = pj_sock_getsockname(fd, &a, &len);
if (status != PJ_SUCCESS) {
pj_sock_close(fd);return status;
}
// COMMENT THE FOLLOWING LINE // pj_sock_close(fd);
Commentthe line 403 in the ioqueue_symbian.cpp file (under
pjproject, pjlib/src/pj/ioqueue_symbian.cpp)
// Call callback.if (cb_.on_accept_complete) { cb_.on_accept_complete( key_, op_key, (pj_sock_t)pjNewSock,
PJ_SUCCESS);}
} // COMMENT THE FOLLOWING LINE //ioqueue_->eventCount++;
5
8/3/2019 Report Ghini Project
6/23
In the filessymbian_ua.mmp (under pjproject) and
jangiu_exe.mmp (under the jangiu project)setthe variables
EPOCSTACKSIZE and EPOCHEAPSIZE to { 0x50000 }
and { 0x50000 0x1000000 } respectively.
EPOCSTACKSIZE 0x50000EPOCHEAPSIZE 0x50000 0x1000000
Figure 2: The Carbide C/C++ IDE
6
8/3/2019 Report Ghini Project
7/23
3. Added features
The two changes made to theJangiu application affect the user-
interface, as shows the image below.
Figure 3: The two changes apported to the user-inteface:1. The search bar2. The groups
7
8/3/2019 Report Ghini Project
8/23
Both the features affect the user-interface, mainly the
contactsdialog.cpp file under thejangiu/src folder. Consequently, in
this chapter, it will be explained how this file has been changed and
how the added code works.
3.1 The search bar
To implement this functionality the following tasks have been
made:
Added the input line in the ui_contactsdialog.h file
Implemented two functions:search() and keyReleaseEvent()
The input line is a Qtfiled and it is not interesting, while the
two functions capture the events on this input line to implement the
search mechanism. Particularly, the keyReleaseEvent() function
waits for a keyboard event (letters, numbers, ) on the input-line
and passes the new content to thesearch() function, that in turn
selects the contacts to display on the top window.
Figure 4: How the keyboard events are handled
8
abab
Insert fInsert f
search(abf)search(abf)
abfabf
input-line
new input-line
8/3/2019 Report Ghini Project
9/23
The following code, taken from the keyReleaseEvent()
function, implements the keyboard event handling:
voidContactsDialog::keyReleaseEvent(QKeyEvent *event){
/**
* STEP 1:* Handling the keyboard*/switch (event->nativeVirtualKey()){
//// Discard all the common non-alphanumeric// keyboard events.//caseEKeyYes:{
event->ignore();break;
}caseEKeyNo:{
event->ignore();break;
}
OTHER NON-ALPHANUMERIC EVENTS
//// Handling the alphanumeric eventsdefault:{
if(event->text()>="0" && event->text()lineEdit_2 is the 'search input-field'//switch(event->text().toInt(&success,10/*base*/)){
case 0:// Do nothing// because button 0 does not contain letters
break;case 1:
// Do nothing// because button 1 does not contain lettersbreak;
9
8/3/2019 Report Ghini Project
10/23
case 2:// Case 2 = charachter 'a'if(success){
// If the search input-field is notfocused
if(!(ui->lineEdit_2->hasFocus())){
// Append the charachter in thefield
ui->lineEdit_2-> insert(QString("a"));
// and set the focus on itui->lineEdit_2->setFocus();
}}break;
case 3:// Case 3 = charachter 'd'if(success){
// If the search input-field is notfocused
if(!(ui->lineEdit_2->hasFocus())){
// Append the charachter in thefield
ui->lineEdit_2-> insert(QString("d"));
// and set the focus on itui->lineEdit_2->setFocus();
}}break;
OTHER CHARACHERS (4 to 9)
default:// Do nothingbreak;
};}else{
10
8/3/2019 Report Ghini Project
11/23
// If the the charachter is not a number// then it is a letter//// Native support for the QWERTY keyboards:// therefore insert automatically the// letter in the search input-field//
if(!(ui->lineEdit_2->hasFocus())){
if(event->text()!="#" && event->text()!="-" &&event->text()!="*" && event->text()!="," &&event->text()!=" " && event->text()!="." &&event->text()!="&" && event->text()!="/" &&event->text()!="+" && event->text()!=";" &&event->text()!="=" && event->text()!="?")
{// Append the charachter in the fieldui->lineEdit_2->insert(event->text());// and set the focus on itui->lineEdit_2->setFocus();
}}
}
/*** STEP 2:* Call the search() function given the prefix*/
//// Once the charachter is been inserted in the// search input-field (lineEdit_2), we can call the// search() function that updates the// contact book, removing all the contacts// that do not begin with the given prefix.//this->search(ui->lineEdit_2->text());
break;}
};#endif
}
As can be seen from the code, the keyReleaseEvent() function
captures the keyboard events and, once populated the input-line withthe inserted character, calls thesearch() function.
11
8/3/2019 Report Ghini Project
12/23
The following code, taken from thesearch() function,
implements the actual search mechanism (implementation with
groups):/*** The search() function updates the contacts list,
* removing all the contacts that do not begin with* the prefix (QString prefix) given in input.*/
voidContactsDialog::search(QString prefix){
QListWidgetItem c;QListWidgetItem *item;// Restore the initial environment, since previus calls to// search() may have changed the list of contacts.//// Therefore re-insert all removed contacts, if anyif(!(this->removedContacts.isEmpty())){
foreach(c, removedContacts){
QListWidgetItem *item = newQListWidgetItem(QIcon(":icons/unknown.png"), c.text());
ui->listWidget->addItem(item);}
}
this->removedContacts.clear();QList contacts=ui->listWidget->
findItems(QString(":"),Qt::MatchContains);
// Remove all groupsfor(int i=0;ilistWidget->count();i++)
if(!ui->listWidget->item(i)->text().contains(":"))ui->listWidget->takeItem(i);
if(!(contacts.isEmpty()) && prefix!=QString("")){
// Entablish the "search" group, composed by all contact// that begins with the given prefixitem = newQListWidgetItem(QIcon(":icons/group.png"),
QString("Search \""+prefix+"\""));item->setFlags(item->flags() & ~Qt::ItemIsSelectable);ui->listWidget->insertItem(0,item);
for(int i=0;itext().split(":").first();
// For each contact: if it does not begin with the// given prefix, remove it (and keep it in the// removedContacts list for future use).if(!contactName.startsWith(prefix)){
this->removedContacts.append(*(contacts.at(i)));
12
8/3/2019 Report Ghini Project
13/23
for(int j=0;jlistWidget->count();j++)if(ui->listWidget->item(j)->
text().split(":").first()==contactName)ui->listWidget->takeItem(j);
}}
}
elseif(prefix==QString(""))// If there is no prefix, then reload the initial contact listreloadContacts();
// Update the contacts listui->listWidget->repaint();
}
The following images show how the search bar works:
Figure 5: The search barWITHOUT groups
13
8/3/2019 Report Ghini Project
14/23
Figure 6: The search barWITH groups
14
8/3/2019 Report Ghini Project
15/23
3.2 The groups
The following functions have been added in order to implement
the groups: getGroups() : returns the list of groups (as (Q)List of (Q)Strings)
removeGroup() : given a contact remove the contact itself from
its group, if it exists
assignGroup() : shows a dialog in which the user can assign a
specific group to a contact
performAssignement() : saves the just-assigned group of thecontact in a specific file on the device
file-system
reloadContacts() : updates the contacts list, displaying all the
contacts with their groups
In addition, the loadContacts() function has been changed.
The groups are saved in a specific file calledjangiuGroups.txt,as shows the following code taken fromperformAssignement(), that
populates that file:
voidContactsDialog::performAssignment(){
if(groupField->text().compare("")){
QFile file("jangiuGroups.txt");
file.open(QIODevice::Append|QIODevice::Text);
QTextStream out(&file);
out currentItem()->text().split(":").first();out
8/3/2019 Report Ghini Project
16/23
file.close();reloadContacts();
}else
errorMessageBox("You haven't inserted any character");}
The following code, from the reloadContacts() function,
updates the window that contains the contacts with their groups:voidContactsDialog::reloadContacts(){
QListWidgetItem *item;QContact currContact;
ui->listWidget->clear();
contactManager = newQContactManager("symbian");
QtMobility::QContactSortOrder order;order.setDetailDefinitionName(QContactName::DefinitionName,
QContactName::FieldCustomLabel);QList contacts = contactManager->contacts();//// LOAD FIRST CONTACTS IN GROUPS//QList groups=getGroups();QList addedContacts;
for(int i=0;isetFlags(item->flags() & ~Qt::ItemIsSelectable);ui->listWidget->addItem(item);
QFile file("jangiuGroups.txt");file.open(QIODevice::ReadOnly|QIODevice::Text);
QTextStream in(&file);
QString currLine;while((currLine=in.readLine(0))!=NULL)
if(currLine.split(":")[1]==groups[i]){
for(int j=0; j
8/3/2019 Report Ghini Project
17/23
detail(QContactOnlineAccount::DefinitionName);QString nameAndNumber= currContact.
DisplayLabel() + ": "+sipUrl.accountUri();
item = newQlistWidgetItem( Qicon(":icons/unknown.png"),
nameAndNumber);ui->listWidget->addItem(item);
addedContacts.insert(0,currLine. split(":")[0]);
break;}
}}
file.close();}
item = newQListWidgetItem(QIcon(":icons/group.png"), QString("No group"));item->setFlags(item->flags() & ~Qt::ItemIsSelectable);
ui->listWidget->addItem(item);
// appends it to list widget to display on screenfor(int i=0; ilistWidget->addItem(item);
}}
}
17
8/3/2019 Report Ghini Project
18/23
The following images show how the groups are implemented:
(a) (b)
Figure 7:
(a) Some contacts with their groups(b)How the user can assign a group to a contact
18
8/3/2019 Report Ghini Project
19/23
(a) (b)
Figure 8:
(a)How assignGroup() works(b) When the search bar is active a new search group is
created
19
8/3/2019 Report Ghini Project
20/23
4. Modularity and Portability
Another interesting issue to be clarified regards theportability
of each added module. Depending to the changes made to the initialproject, can be defined essentially two modules:
A first module with all its function that implements the search
function
And a second module that implements the groups
The first module relies on the keyReleaseEvent() function that
is strictly dependent from theSymbian environment, because it islinked with the keyboards. By contrast, the second module depends
only by the Qtlibraries, that are not correlate with a specific device.
The following image can clarify the concept:
Figure 9:Portability of each module added to the Jangiu application
20
QtQt
SymbianSymbian
Module 1(search bar)
Module 1(search bar)
Module 2(groups)
Module 2(groups)
8/3/2019 Report Ghini Project
21/23
Note that it will be possible to adapt the first module to each
device (and O.S.) simply changing the keyReleaseEvent() function,
that handles the device keyboard. One solution could be to remove
the #ifdefC statement [9] within the function.
/// Search-contacts implementation begins here//voidContactsDialog::keyReleaseEvent(QKeyEvent *event){
//// Native support for both 0-9 keyboard// and QWERTY keyboard//
#ifdef Q_OS_SYMBIAN/*** STEP 1:* Handling the keyboard*/
21
8/3/2019 Report Ghini Project
22/23
5. Future development
In terms of user interface (and beyond) theJangiu applicationcan be extended with the following utilities:
Possibility to switch among various different conversations, for
example using tabs
Extend interoperability, for example making calls with other
clients
Backup of all the previous conversations
Conversations with unconnected users, for example relying on adatabase
Possibility to associate various different SIP addresses to one
contact
Shared rooms (send and receive messages among various
contacts)
Encrypt the outgoing data
Adding a shared (other contacts can see it) string to thecontact fields that describes its state, likefacebook[10]
Adding emoticon icons [11] to messages
22
8/3/2019 Report Ghini Project
23/23
References
[1] Giulio Massaccesi, Un'applicazione VoIP per Symbian: Architettura. Tesidi Laurea (Thesis) [AY 2009-2010], University of Bologna.[2] http://en.wikipedia.org/wiki/Graphical_user_interface
[3] http://en.wikipedia.org/wiki/Symbian
[4] http://qt.nokia.com/products/
[5] http://en.wikipedia.org/wiki/Session_Initiation_Protocol
[6] http://en.wikipedia.org/wiki/Carbide.c%2B%2B
[7] http://www.developer.nokia.com/Resources/Tools_and_downloads/Other/Symbian_SDKs/
[8] http://www.pjsip.org/
[9] http://en.wikipedia.org/wiki/C_preprocessor
[10] http://en.wikipedia.org/wiki/Facebook
[11] http://en.wikipedia.org/wiki/Emoticon
23
http://en.wikipedia.org/wiki/Graphical_user_interfacehttp://en.wikipedia.org/wiki/Symbianhttp://qt.nokia.com/products/http://en.wikipedia.org/wiki/Session_Initiation_Protocolhttp://en.wikipedia.org/wiki/Carbide.c%2B%2Bhttp://www.developer.nokia.com/Resources/Tools_and_downloads/Other/Symbian_SDKs/http://www.pjsip.org/http://en.wikipedia.org/wiki/C_preprocessorhttp://en.wikipedia.org/wiki/Facebookhttp://en.wikipedia.org/wiki/Emoticonhttp://en.wikipedia.org/wiki/Symbianhttp://qt.nokia.com/products/http://en.wikipedia.org/wiki/Session_Initiation_Protocolhttp://en.wikipedia.org/wiki/Carbide.c%2B%2Bhttp://www.developer.nokia.com/Resources/Tools_and_downloads/Other/Symbian_SDKs/http://www.pjsip.org/http://en.wikipedia.org/wiki/C_preprocessorhttp://en.wikipedia.org/wiki/Facebookhttp://en.wikipedia.org/wiki/Emoticonhttp://en.wikipedia.org/wiki/Graphical_user_interfaceRecommended