[SailfishDevel] Fwd: Re: Re: How to get contacts and sms through Qt(C++)

christopher.lamb at thurweb.ch christopher.lamb at thurweb.ch
Sun Dec 22 15:58:42 UTC 2013


Hi Jonni

Thanks, I mentioned that at earlier in this thread.

However I think that the harbour rule is too strict. I think there is  
a legitimate case for apps that clearly state that their purpose is to  
send SMSes, and have their own send button --> i.e. SMSes are only  
sent with explicit permission of the user at time of sending.

Chris


Zitat von "Jonni Rainisto" <jonni.rainisto at jolla.com>:

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





More information about the Devel mailing list