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

2013-12-25 Thread christopher . lamb

Andrey

That solution would be perfect for me, I would have no problem with  
supplying the code. The sources for the Harmattan version are out  
there on Github already, and the Sailfish sources soon will be.


In theory it might even be possible to separate the SMS bit of my app,  
including the control used to display the text, name and number + send  
button into a separate shared library C++ that would be called by my  
app. My app would simply provide the SMS body and the name of number  
of the chosen contact, and the library would take care of the rest.  
This would reduce the amount of code that would need to be audited.  
(At the moment the GUI bits are QML, I would need to do some thinking  
about how to move these to C++)



Chris

Zitat von "Andrey Kozhevnikov" :

Maybe an option to share sources to jolla QA or even letting them to  
build application from sources and uploading to store to be 100%  
sure in usecase?


On 25.12.2013 17:08, christopher.l...@thurweb.ch wrote:

Hi Bernd

Thanks for your interest.

I understand that there is a strong need to prevent apps that send  
SMSes without the user's consent (a security issue), or to premium  
SMS numbers, thereby defrauding the user.


But we should not throw out the baby with the bathwater. There will  
be apps where SMS sending / handling is a primary part of the  
use-case, and where the user willingly consents to each SMS being  
sent by that app.


My own use-case (simplified) is this:
My main hobby is paragliding. Mostly we land close to where we  
started (at the foot of the mountain), but sometime we go  
cross-country and land many kilometres away, and need to  
communicate back to a recovery team the GPS location of the landing  
site.


The secondary use-case (secondary only because it should be far  
less often used). Is the emergency situation. You have landed in a  
tree, or as happened to me at the start of this year, are stuck on  
a cold and snowy mountain slope with darkness approaching. Here you  
need to alert the recovery team with your location, and the fact  
that your status is NOT OK.


My app uses GPS and SMS to achieve this. Before flying the user  
sets up a number of SMS templates (basically pre-filled messages to  
which GPS coords will later be added. On landing the user fires up  
the app, which starts the GPS. Once the GPS has acquired a fix, the  
user can then chose between "Ok" and "Status NOT Ok" SMSes. Based  
on this choice, the appropriate SMS template is taken, the GPS  
coords are added to this, and a pre-selected contact associated  
with the SMS template is chosen. The user sees both the text of the  
SMS, and the chosen contact name and number.


At this point the user can press "send", and the SMS is sent to the  
displayed contact. He also has the option of adding further text to  
the SMS, and of changing the contact.


The aim is that he user should be able to send the SMS with an  
absolute minimum of button presses, either because he may be tired  
(Ok Situation), or because he is tired / injured / cold / wet  
(Emergency situation). On the Harmattan version of the app I have  
one press to open the app, a second to chose between Ok / Not Ok,  
and a third for Send. In this case the phone may be being used at  
the limits of touchscreen capabilities (cold and wet), so big  
buttons are called for.


It is in no way concealed from the user that the app sends SMSes:  
Indeed it is the purpose of the app.


There are other apps out there with similar use cases. The Swiss  
Helicopter rescue service REGA have one for iOS and Android.


Later I intend to make "the other half": in this case an app for  
the Recovery team, that would pick incoming landed SMSes from  
pilots, and display distance and bearing for each of these relevant  
to the position of the recovery team.


Happy Christmas all.

Chris



Zitat von "Bernd Wachter" :


 writes:


Hi Bernd

Thanks, I am aware of that, but I think it is an inelegant solution,
acceptable ad interim as a workaround, but not longterm.


Allowing arbitrary applications to send SMS brings a big cost risk for
the user, due to all the premium SMS services out there -> it'll only be
possible once we enforce proper application permissions.


My app is designed for emergency use, must be easy to use as possible,
and therefore I require a larger send button. I know from personal
experience that trying to operate a mobile when it is wet and below
zero degrees is not easy (at the very edge of the capabilities of
touch screen technology).


Can you describe what exactly you're trying to do?

Bernd






___
SailfishOS.org Devel mailing list


___
SailfishOS.org Devel mailing list





___
SailfishOS.org Devel mailing list


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

2013-12-25 Thread Seppo Tiainen
Hi,

I just tested SMS transmission by QML by using method
Qt.openUrlExternally("sms:01234567444" + "?body=" + "bodytext") on my Jolla
device with OS version 1.0.1.12, sending to my N9.

It seems to work fine but there is a danger with it too: You cannot see to
whom the message is going. The is no indication of the contact or the
recipient tel.number visible. So, when you press enter to finally send the
SMS, you just have to trust that the application is not going to send this
message e.g. to an expensive money collecting number now and then.

I would propose to add a clear contact indication on the SMS message thread
display for the next OS update.

seppo



2013/12/24 Bernd Wachter 

>  writes:
>
> Hi,
>
> > 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.
>
> the upcoming update introduces sms: as supported URL scheme for
> xdg-open, so in the future your application may send SMS by using
> xdg-open to call an URL like sms:12345?body=foo+bar+baz, which will open
> the messages application with number and body prefilled, and just
> requires the user to press 'send'.
>
> Bernd
>
> ___
> SailfishOS.org Devel mailing list
>
___
SailfishOS.org Devel mailing list

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

2013-12-25 Thread Andrey Kozhevnikov
Maybe an option to share sources to jolla QA or even letting them to 
build application from sources and uploading to store to be 100% sure in 
usecase?


On 25.12.2013 17:08, christopher.l...@thurweb.ch wrote:

Hi Bernd

Thanks for your interest.

I understand that there is a strong need to prevent apps that send 
SMSes without the user's consent (a security issue), or to premium SMS 
numbers, thereby defrauding the user.


But we should not throw out the baby with the bathwater. There will be 
apps where SMS sending / handling is a primary part of the use-case, 
and where the user willingly consents to each SMS being sent by that app.


My own use-case (simplified) is this:
My main hobby is paragliding. Mostly we land close to where we started 
(at the foot of the mountain), but sometime we go cross-country and 
land many kilometres away, and need to communicate back to a recovery 
team the GPS location of the landing site.


The secondary use-case (secondary only because it should be far less 
often used). Is the emergency situation. You have landed in a tree, or 
as happened to me at the start of this year, are stuck on a cold and 
snowy mountain slope with darkness approaching. Here you need to alert 
the recovery team with your location, and the fact that your status is 
NOT OK.


My app uses GPS and SMS to achieve this. Before flying the user sets 
up a number of SMS templates (basically pre-filled messages to which 
GPS coords will later be added. On landing the user fires up the app, 
which starts the GPS. Once the GPS has acquired a fix, the user can 
then chose between "Ok" and "Status NOT Ok" SMSes. Based on this 
choice, the appropriate SMS template is taken, the GPS coords are 
added to this, and a pre-selected contact associated with the SMS 
template is chosen. The user sees both the text of the SMS, and the 
chosen contact name and number.


At this point the user can press "send", and the SMS is sent to the 
displayed contact. He also has the option of adding further text to 
the SMS, and of changing the contact.


The aim is that he user should be able to send the SMS with an 
absolute minimum of button presses, either because he may be tired (Ok 
Situation), or because he is tired / injured / cold / wet (Emergency 
situation). On the Harmattan version of the app I have one press to 
open the app, a second to chose between Ok / Not Ok, and a third for 
Send. In this case the phone may be being used at the limits of 
touchscreen capabilities (cold and wet), so big buttons are called for.


It is in no way concealed from the user that the app sends SMSes: 
Indeed it is the purpose of the app.


There are other apps out there with similar use cases. The Swiss 
Helicopter rescue service REGA have one for iOS and Android.


Later I intend to make "the other half": in this case an app for the 
Recovery team, that would pick incoming landed SMSes from pilots, and 
display distance and bearing for each of these relevant to the 
position of the recovery team.


Happy Christmas all.

Chris



Zitat von "Bernd Wachter" :


 writes:


Hi Bernd

Thanks, I am aware of that, but I think it is an inelegant solution,
acceptable ad interim as a workaround, but not longterm.


Allowing arbitrary applications to send SMS brings a big cost risk for
the user, due to all the premium SMS services out there -> it'll only be
possible once we enforce proper application permissions.


My app is designed for emergency use, must be easy to use as possible,
and therefore I require a larger send button. I know from personal
experience that trying to operate a mobile when it is wet and below
zero degrees is not easy (at the very edge of the capabilities of
touch screen technology).


Can you describe what exactly you're trying to do?

Bernd






___
SailfishOS.org Devel mailing list


___
SailfishOS.org Devel mailing list


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

2013-12-25 Thread christopher . lamb

Hi Bernd

Thanks for your interest.

I understand that there is a strong need to prevent apps that send  
SMSes without the user's consent (a security issue), or to premium SMS  
numbers, thereby defrauding the user.


But we should not throw out the baby with the bathwater. There will be  
apps where SMS sending / handling is a primary part of the use-case,  
and where the user willingly consents to each SMS being sent by that  
app.


My own use-case (simplified) is this:
My main hobby is paragliding. Mostly we land close to where we started  
(at the foot of the mountain), but sometime we go cross-country and  
land many kilometres away, and need to communicate back to a recovery  
team the GPS location of the landing site.


The secondary use-case (secondary only because it should be far less  
often used). Is the emergency situation. You have landed in a tree, or  
as happened to me at the start of this year, are stuck on a cold and  
snowy mountain slope with darkness approaching. Here you need to alert  
the recovery team with your location, and the fact that your status is  
NOT OK.


My app uses GPS and SMS to achieve this. Before flying the user sets  
up a number of SMS templates (basically pre-filled messages to which  
GPS coords will later be added. On landing the user fires up the app,  
which starts the GPS. Once the GPS has acquired a fix, the user can  
then chose between "Ok" and "Status NOT Ok" SMSes. Based on this  
choice, the appropriate SMS template is taken, the GPS coords are  
added to this, and a pre-selected contact associated with the SMS  
template is chosen. The user sees both the text of the SMS, and the  
chosen contact name and number.


At this point the user can press "send", and the SMS is sent to the  
displayed contact. He also has the option of adding further text to  
the SMS, and of changing the contact.


The aim is that he user should be able to send the SMS with an  
absolute minimum of button presses, either because he may be tired (Ok  
Situation), or because he is tired / injured / cold / wet (Emergency  
situation). On the Harmattan version of the app I have one press to  
open the app, a second to chose between Ok / Not Ok, and a third for  
Send. In this case the phone may be being used at the limits of  
touchscreen capabilities (cold and wet), so big buttons are called for.


It is in no way concealed from the user that the app sends SMSes:  
Indeed it is the purpose of the app.


There are other apps out there with similar use cases. The Swiss  
Helicopter rescue service REGA have one for iOS and Android.


Later I intend to make "the other half": in this case an app for the  
Recovery team, that would pick incoming landed SMSes from pilots, and  
display distance and bearing for each of these relevant to the  
position of the recovery team.


Happy Christmas all.

Chris



Zitat von "Bernd Wachter" :


 writes:


Hi Bernd

Thanks, I am aware of that, but I think it is an inelegant solution,
acceptable ad interim as a workaround, but not longterm.


Allowing arbitrary applications to send SMS brings a big cost risk for
the user, due to all the premium SMS services out there -> it'll only be
possible once we enforce proper application permissions.


My app is designed for emergency use, must be easy to use as possible,
and therefore I require a larger send button. I know from personal
experience that trying to operate a mobile when it is wet and below
zero degrees is not easy (at the very edge of the capabilities of
touch screen technology).


Can you describe what exactly you're trying to do?

Bernd






___
SailfishOS.org Devel mailing list


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

2013-12-24 Thread itviewer
Hi ,
 In fact, My intention(purpose) is not the independent Sailfish's app,
what I really want is a desktop software,that just like the iTunes for the 
iphone, a data 
synchronization application between the phone and pc.

The working mechanism is probably that the app which is installed on the phone 
can get 
the music、video、picture、contacts and SMS information by the related SailfishOS 
API,then 
deliver it to the computer client software by some way. 

In this way the user can do some create、delete and update operation.the 
operation result can be 
synchronized to the phone(need in develop mode).

As for the Android, we can get the various needed information by the API or 
directly operating the 
sqllite database(root limits of authority ).while when faced with the new 
SailfishOS, I can't get any reference
document that can achieve the purpose.

So I desire some help about the realization of this mechanism.

Best 
Yours sincerely

===
maxinjun 

From: Bernd Wachter
Date: 2013-12-25 06:13
To: christopher.l...@thurweb.ch
CC: Sailfish OS Developers; Jonni Rainisto
Subject: Re: [SailfishDevel] Fwd: Re: Re: How to get contacts and sms through 
Qt(C++)
 writes:

> Hi Bernd
>
> Thanks, I am aware of that, but I think it is an inelegant solution,
> acceptable ad interim as a workaround, but not longterm.

Allowing arbitrary applications to send SMS brings a big cost risk for
the user, due to all the premium SMS services out there -> it'll only be
possible once we enforce proper application permissions.

> My app is designed for emergency use, must be easy to use as possible,
> and therefore I require a larger send button. I know from personal
> experience that trying to operate a mobile when it is wet and below
> zero degrees is not easy (at the very edge of the capabilities of
> touch screen technology).

Can you describe what exactly you're trying to do? 

Bernd

___
SailfishOS.org Devel mailing list___
SailfishOS.org Devel mailing list

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

2013-12-24 Thread Bernd Wachter
 writes:

> Hi Bernd
>
> Thanks, I am aware of that, but I think it is an inelegant solution,
> acceptable ad interim as a workaround, but not longterm.

Allowing arbitrary applications to send SMS brings a big cost risk for
the user, due to all the premium SMS services out there -> it'll only be
possible once we enforce proper application permissions.

> My app is designed for emergency use, must be easy to use as possible,
> and therefore I require a larger send button. I know from personal
> experience that trying to operate a mobile when it is wet and below
> zero degrees is not easy (at the very edge of the capabilities of
> touch screen technology).

Can you describe what exactly you're trying to do? 

Bernd

___
SailfishOS.org Devel mailing list


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

2013-12-24 Thread christopher . lamb

Hi Bernd

Thanks, I am aware of that, but I think it is an inelegant solution,  
acceptable ad interim as a workaround, but not longterm.


I have not yet seen the SMS app on a real device, but the one on my  
Nokia N9 has a tiny send button.


My app is designed for emergency use, must be easy to use as possible,  
and therefore I require a larger send button. I know from personal  
experience that trying to operate a mobile when it is wet and below  
zero degrees is not easy (at the very edge of the capabilities of  
touch screen technology).


I can also imagine a use-case for an alternative "large print" SMS  
Client  for the visually impaired. Again on my N9 the font used is so  
small 


Chris


Zitat von "Bernd Wachter" :


 writes:

Hi,


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.


the upcoming update introduces sms: as supported URL scheme for
xdg-open, so in the future your application may send SMS by using
xdg-open to call an URL like sms:12345?body=foo+bar+baz, which will open
the messages application with number and body prefilled, and just
requires the user to press 'send'.

Bernd

___
SailfishOS.org Devel mailing list





___
SailfishOS.org Devel mailing list


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

2013-12-24 Thread Bernd Wachter
 writes:

Hi,

> 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.

the upcoming update introduces sms: as supported URL scheme for
xdg-open, so in the future your application may send SMS by using
xdg-open to call an URL like sms:12345?body=foo+bar+baz, which will open
the messages application with number and body prefilled, and just
requires the user to press 'send'.

Bernd 

___
SailfishOS.org Devel mailing list


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

2013-12-22 Thread christopher . lamb

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" :

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-boun...@lists.sailfishos.org  
[devel-boun...@lists.sailfishos.org] on behalf of  
christopher.l...@thurweb.ch [christopher.l...@thurweb.ch]

Sent: Sunday, December 22, 2013 12:55 PM
To: itviewer; devel@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 

#include 
#include 

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 
#include 
#include 
#include 
#include 
#include 


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(op);

 qDebug() << "Message sent, token is" << psm->sentMessageToken();
 emit stateMsg("FinishedState");
}

//end telepathy.cpp

- Weitergeleitete Nachricht von itvie...@jolladev.net -
  Datum: Sun, 22 Dec 2013 17:36:18 +0800
Von: itviewer 
Betreff: Re: Re: [SailfishDevel] How to get contacts and sms
through Qt(C++)
 An: c

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

2013-12-22 Thread Jonni Rainisto
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-boun...@lists.sailfishos.org [devel-boun...@lists.sailfishos.org] 
on behalf of christopher.l...@thurweb.ch [christopher.l...@thurweb.ch]
Sent: Sunday, December 22, 2013 12:55 PM
To: itviewer; devel@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 

#include 
#include 

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 
#include 
#include 
#include 
#include 
#include 


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(op);
 qDebug() << "Message sent, token is" << psm->sentMessageToken();
 emit stateMsg("FinishedState");
}

//end telepathy.cpp

- Weitergeleitete Nachricht von itvie...@jolladev.net -
  Datum: Sun, 22 Dec 2013 17:36:18 +0800
Von: itviewer 
Betreff: Re: Re: [SailfishDevel] How to get contacts and sms
through Qt(C++)
 An: christopher.lamb 

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 sear

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

2013-12-22 Thread christopher . lamb

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 

#include 
#include 

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 
#include 
#include 
#include 
#include 
#include 


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(op);
qDebug() << "Message sent, token is" << psm->sentMessageToken();
emit stateMsg("FinishedState");
}

//end telepathy.cpp

- Weitergeleitete Nachricht von itvie...@jolladev.net -
 Datum: Sun, 22 Dec 2013 17:36:18 +0800
   Von: itviewer 
   Betreff: Re: Re: [SailfishDevel] How to get contacts and sms  
through Qt(C++)

An: christopher.lamb 

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 :


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