<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>
BLOCKQUOTE {
        MARGIN-BOTTOM: 0px; MARGIN-LEFT: 2em; MARGIN-TOP: 0px
}
OL {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
UL {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
P {
        MARGIN-BOTTOM: 0px; MARGIN-TOP: 0px
}
BODY {
        FONT-SIZE: 10.5pt; FONT-FAMILY: 微软雅黑; COLOR: #000000; LINE-HEIGHT: 1.5
}
</STYLE>

<META name=GENERATOR content="MSHTML 11.00.9600.16384"></HEAD>
<BODY style="MARGIN: 10px">
<DIV>Hi Chris</DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN lang=en id=result_box class=short_text><SPAN 
class=hps>Thank you very much  for your guidance,<SPAN lang=en 
id=result_box class=short_text><SPAN class=hps>It's</SPAN> <SPAN class=hps>very 
helpful</SPAN> <SPAN class=hps>for me and <SPAN lang=en id=result_box 
class=short_text><SPAN class=hps>I will</SPAN> <SPAN class=hps>try</SPAN> <SPAN 
class=hps>as your use-case.</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN lang=en class=short_text><SPAN 
class=hps><SPAN lang=en class=short_text><SPAN class=hps><SPAN lang=en 
class=short_text><SPAN 
class=hps></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN> </DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN lang=en class=short_text><SPAN 
class=hps><SPAN lang=en class=short_text><SPAN class=hps><SPAN lang=en 
class=short_text><SPAN class=hps><SPAN lang=en class=short_text><SPAN 
class=hps>My mother tongue is</SPAN> <SPAN class=hps>Chinese and <SPAN lang=en 
id=result_box class=short_text><SPAN class=hps>my English is</SPAN> <SPAN 
class=hps>so-so<IMG border=0 
src="cid:_Foxmail.0@88AEB719-88CC-4713-BCC8-B5251404A2AC">. 
</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"><SPAN lang=en class=short_text><SPAN 
class=hps><SPAN lang=en class=short_text><SPAN class=hps><SPAN lang=en 
class=short_text><SPAN class=hps><SPAN lang=en class=short_text><SPAN 
class=hps><SPAN lang=en class=short_text><SPAN class=hps>Wishing you and your 
family a very merry Christmas. 
</SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></SPAN></DIV>
<DIV style="TEXT-INDENT: 2em"> </DIV>
<HR style="HEIGHT: 1px; WIDTH: 210px" align=left color=#b5c4df SIZE=1>

<DIV><SPAN>
<DIV 
style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000; MARGIN-LEFT: 10px; MARGIN-TOP: 10px; MARGIN-RIGHT: 10px">
<DIV><SPAN 
style="FONT-SIZE: 10.5pt; FONT-FAMILY: 宋体; COLOR: #000000">maxinjun </SPAN></DIV></DIV></SPAN>
<DIV 
style="FONT-SIZE: 10pt; FONT-FAMILY: verdana; MARGIN: 10px"> </DIV></DIV>
<DIV 
style="BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; BORDER-BOTTOM: medium none; PADDING-BOTTOM: 0cm; PADDING-TOP: 3pt; PADDING-LEFT: 0cm; BORDER-LEFT: medium none; PADDING-RIGHT: 0cm">
<DIV 
style="FONT-SIZE: 12px; FONT-FAMILY: tahoma; BACKGROUND: #efefef; COLOR: #000000; PADDING-BOTTOM: 8px; PADDING-TOP: 8px; PADDING-LEFT: 8px; PADDING-RIGHT: 8px">
<DIV><B>From:</B> <A 
href="mailto:christopher.lamb@thurweb.ch">christopher.lamb</A></DIV>
<DIV><B>Date:</B> 2013-12-22 18:55</DIV>
<DIV><B>To:</B> <A href="mailto:itviewer@jolladev.net">itviewer</A>; <A 
href="mailto:devel@lists.sailfishos.org">devel@lists.sailfishos.org</A></DIV>
<DIV><B>Subject:</B> Fwd: Re: Re: [SailfishDevel] How to get contacts and 
sms through Qt(C++)</DIV></DIV></DIV>
<DIV>
<DIV>Hi Max</DIV>
<DIV> </DIV>
<DIV>No problem, your english is excellent. What is your mother language?</DIV>
<DIV> </DIV>
<DIV>I am visiting family for Christmas at the moment, so I will keep this  
</DIV>
<DIV>first mail short. I will try and post again this evening.</DIV>
<DIV> </DIV>
<DIV>So first, SMS: In my app I only need to send smses, and I do it using  
</DIV>
<DIV>the Telepathy library. My explanation below reflects how "I did it"  
</DIV>
<DIV>and my use-case, but there are other routes you can take.</DIV>
<DIV> </DIV>
<DIV>The C++ code I am using is at the bottom of this mail.</DIV>
<DIV> </DIV>
<DIV>Note this is ported from Harmattan, and not fully tested yet as my  
</DIV>
<DIV>Sailfish app is not fully ported, and I only have the Emulator. No  
</DIV>
<DIV>sign of my phone arriving ...</DIV>
<DIV> </DIV>
<DIV>On Harmattan I originally used the Mobility API, but as that API had 
a  </DIV>
<DIV>very negative effect on app startup time, and is not available for 
Qt5  </DIV>
<DIV>/ Sailfish, I wrote code similar to that below for Harmattan, and was  
</DIV>
<DIV>able to test it with a real Nokia N9.</DIV>
<DIV> </DIV>
<DIV>//in the .pro file</DIV>
<DIV> </DIV>
<DIV>QT += dbus</DIV>
<DIV> </DIV>
<DIV>PKGCONFIG += TelepathyQt5</DIV>
<DIV> </DIV>
<DIV>Note I need to play around more with the .pro file settings, but with  
</DIV>
<DIV>the ones above, Telepathy is found, and the code compiles.</DIV>
<DIV> </DIV>
<DIV>Note also that the account used below is almost certainly wrong for  
</DIV>
<DIV>Sailfish, it is the one that works on the N9.</DIV>
<DIV> </DIV>
<DIV>You also need to make sure that the correct Telepathy Modules are  
</DIV>
<DIV>installed. I will post more on this later, but for now I think you  
</DIV>
<DIV>will need</DIV>
<DIV>telepathy-ring-devel, telepathy-mission-control, telepathy-qt5-devel.</DIV>
<DIV> </DIV>
<DIV>I will post separately on QtContacts in the next few days, as and 
when  </DIV>
<DIV>Christmas / family festivities permit.</DIV>
<DIV> </DIV>
<DIV>Ciao</DIV>
<DIV> </DIV>
<DIV>Chris</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>//start telepathy.h</DIV>
<DIV>#ifndef TELEPATHYHELPER_H</DIV>
<DIV>#define TELEPATHYHELPER_H</DIV>
<DIV> </DIV>
<DIV>#include <TelepathyQt/Types></DIV>
<DIV> </DIV>
<DIV>#include <QObject></DIV>
<DIV>#include <QString></DIV>
<DIV> </DIV>
<DIV>namespace Tp</DIV>
<DIV>{</DIV>
<DIV>     class PendingOperation;</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>class TelepathyHelper : public QObject</DIV>
<DIV>{</DIV>
<DIV>     Q_OBJECT</DIV>
<DIV> </DIV>
<DIV>public:</DIV>
<DIV>     explicit TelepathyHelper(QObject *parent = 
0);</DIV>
<DIV>     ~TelepathyHelper();</DIV>
<DIV>     Q_INVOKABLE void sendSMS(const QString 
&contactIdentifier, const  </DIV>
<DIV>QString &message);</DIV>
<DIV> </DIV>
<DIV>signals:</DIV>
<DIV>     void stateMsg(const QString &statemsg);</DIV>
<DIV>     void errorMsg(const QString &errormsg);</DIV>
<DIV> </DIV>
<DIV>private Q_SLOTS:</DIV>
<DIV>     void onSendMessageFinished(Tp::PendingOperation 
*op);</DIV>
<DIV> </DIV>
<DIV>private:</DIV>
<DIV> </DIV>
<DIV>     Tp::ContactMessengerPtr messenger;</DIV>
<DIV> </DIV>
<DIV>};</DIV>
<DIV> </DIV>
<DIV>#endif // TELEPATHYHELPER_H</DIV>
<DIV>//end //start telepathy.h</DIV>
<DIV> </DIV>
<DIV>//start telepathy.cpp</DIV>
<DIV>#include "telepathyhelper.h"</DIV>
<DIV> </DIV>
<DIV>#include <TelepathyQt/Account></DIV>
<DIV>#include <TelepathyQt/Debug></DIV>
<DIV>#include <TelepathyQt/Constants></DIV>
<DIV>#include <TelepathyQt/ContactMessenger></DIV>
<DIV>#include <TelepathyQt/PendingSendMessage></DIV>
<DIV>#include <TelepathyQt/Types></DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>TelepathyHelper::TelepathyHelper(QObject *parent) :</DIV>
<DIV>     QObject(parent)</DIV>
<DIV>{</DIV>
<DIV> </DIV>
<DIV>     Tp::registerTypes();</DIV>
<DIV>     Tp::enableDebug(true);</DIV>
<DIV>     Tp::enableWarnings(true);</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>TelepathyHelper::~TelepathyHelper()</DIV>
<DIV>{</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>void TelepathyHelper::sendSMS(const QString &contactIdentifier, 
const  </DIV>
<DIV>QString &message)</DIV>
<DIV>{</DIV>
<DIV> </DIV>
<DIV>     Tp::AccountPtr acc = 
Tp::Account::create(TP_QT_ACCOUNT_MANAGER_BUS_NAME,</DIV>
<DIV>                                               
</DIV>
<DIV>QLatin1String("/org/freedesktop/Telepathy/Account/ring/tel/ring"));</DIV>
<DIV>     
//QLatin1String("/org/freedesktop/Telepathy/Account/ring/tel/account0"));</DIV>
<DIV>     messenger = Tp::ContactMessenger::create(acc, 
contactIdentifier);</DIV>
<DIV> </DIV>
<DIV>     connect(messenger->sendMessage(message),</DIV>
<DIV>             
SIGNAL(finished(Tp::PendingOperation*)),</DIV>
<DIV>             
SLOT(onSendMessageFinished(Tp::PendingOperation*)));</DIV>
<DIV> </DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>void TelepathyHelper::onSendMessageFinished(Tp::PendingOperation *op)</DIV>
<DIV>{</DIV>
<DIV>     if (op->isError()) {</DIV>
<DIV>         qDebug() << "Error 
sending message:" << op->errorName() <<  </DIV>
<DIV>"-" << op->errorMessage();</DIV>
<DIV>         emit errorMsg("Error 
sending message");</DIV>
<DIV>         return;</DIV>
<DIV>     }</DIV>
<DIV> </DIV>
<DIV>     Tp::PendingSendMessage *psm = 
qobject_cast<Tp::PendingSendMessage *>(op);</DIV>
<DIV>     qDebug() << "Message sent, token is" 
<< psm->sentMessageToken();</DIV>
<DIV>     emit stateMsg("FinishedState");</DIV>
<DIV>}</DIV>
<DIV> </DIV>
<DIV>//end telepathy.cpp</DIV>
<DIV> </DIV>
<DIV>----- Weitergeleitete Nachricht von itviewer@jolladev.net -----</DIV>
<DIV>      Datum: Sun, 22 Dec 2013 17:36:18 +0800</DIV>
<DIV>        Von: itviewer 
<itviewer@jolladev.net></DIV>
<DIV>    Betreff: Re: Re: [SailfishDevel] How to get contacts and 
sms  </DIV>
<DIV>through Qt(C++)</DIV>
<DIV>         An: christopher.lamb 
<christopher.lamb@thurweb.ch></DIV>
<DIV> </DIV>
<DIV>Hi Chris</DIV>
<DIV>Thanks for your help,I  reviewed all your posts ,however, I still 
do  </DIV>
<DIV>not know how to start.</DIV>
<DIV>Will you be able to provide some cases I can refer to?</DIV>
<DIV> </DIV>
<DIV>Thank you and sorry for my english.</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>maxinjun</DIV>
<DIV> </DIV>
<DIV>From: christopher.lamb</DIV>
<DIV>Date: 2013-12-22 15:59</DIV>
<DIV>To: Sailfish OS Developers; itviewer</DIV>
<DIV>CC: devel</DIV>
<DIV>Subject: Re: [SailfishDevel] How to get contacts and sms through 
Qt(C++)</DIV>
<DIV>Hi myinjun</DIV>
<DIV> </DIV>
<DIV>If you search through the archives of this mailing list, especially</DIV>
<DIV>for posts with my name you will find some stuff on Sailfish and SMS.</DIV>
<DIV> </DIV>
<DIV>I was able to get SMS working (as far as that is possible) on the</DIV>
<DIV>Emulator using the Telepathy libraries.</DIV>
<DIV> </DIV>
<DIV>Note however that currently that will probably be a no-no for</DIV>
<DIV>inclusion in the Harbour Store.</DIV>
<DIV> </DIV>
<DIV>For Contacts access, see the recent thread on QtContact.</DIV>
<DIV> </DIV>
<DIV>Chris</DIV>
<DIV> </DIV>
<DIV>Zitat von itviewer <itviewer@jolladev.net>:</DIV>
<DIV> </DIV>
<DIV>> Hi,</DIV>
<DIV>> I want to manage contacts and sms message through Qt C++?how can 
i</DIV>
<DIV>> do that?Are there any helpful documents?</DIV>
<DIV>> Any pointers whatsoever would be highly appreciated.</DIV>
<DIV>> thanks</DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>></DIV>
<DIV>> maxinjun</DIV>
<DIV> </DIV>
<DIV>----- Ende der weitergeleiteten Nachricht -----</DIV>
<DIV> </DIV>
<DIV> </DIV></DIV></BODY></HTML>