X-Git-Url: https://vcs.maemo.org/git/?a=blobdiff_plain;f=tpsession-0.1%2Ftpsession%2Ftpsessionaccount.cpp;h=2c0668a51ee233e3e570c570ebc02575def3980a;hb=39c01267eba450aed214c0b91fda0d9c45245a57;hp=880578ad0c66175a699dc7238d4cbfa0c56092e2;hpb=fa60d89533e6cc5cfdda4a7fea370ab86cbe6faa;p=tpsession diff --git a/tpsession-0.1/tpsession/tpsessionaccount.cpp b/tpsession-0.1/tpsession/tpsessionaccount.cpp index 880578a..2c0668a 100644 --- a/tpsession-0.1/tpsession/tpsessionaccount.cpp +++ b/tpsession-0.1/tpsession/tpsessionaccount.cpp @@ -21,6 +21,44 @@ #include "tpsessionaccount.h" #include +/** + * \class TpSessionAccount + * \headerfile + * + * TpSessionAccount class represents every account you have. As example account for “Ring” connection manager represents your cellular + * account and you may send and receive SMS with it. Gabble represents your GoogleTalk account if you have defined them. + * TpSessionAccounts are created by TpSession class,they are not intended to be created stand-alone + + */ +/** + * \fn void TpSessionAccount::accountReady(TpSessionAccount *); + * + * Emitted when the account becomes ready + * + * \param TpSessionAccount pointer to account become ready + */ +/** + * \fn void TpSessionAccount::channelReady(TpSessionAccount *); + * + * Emitted when the account Manager becomes ready + * + * \param TpSession pointer to TpSession class + */ +/** + * \fn void TpSessionAccount::messageReceived(const Tp::ReceivedMessage &,TpSessionAccount *); + * + * Emitted when any of Account Managers recived message + * + * \param Tp::ReceivedMessage Message received + * \param TpSessionAccount pointer to account received message + */ + +/** + * Construct a new TpSessionAccount object. This constructor is called by TpSession class when new account is created or fetched from account manager. It is not inended to be used stand alone + * + * \param am Telepathy-Qt4 account manager for this account + * \param objectPath Dbus object path tonew account + */ TpSessionAccount::TpSessionAccount(Tp::AccountManagerPtr am,const QString &objectPath): mAcc(Tp::Account::create(am->dbusConnection(),am->busName(), objectPath)) @@ -92,6 +130,16 @@ void TpSessionAccount::onContactsConnectionReady(Tp::PendingOperation *op) emit accountReady(this); } + +/** + * Fetch Tp::ContactPtr for contact with given address. Contact is searched among contacts returned by contact manager for ths account. + * All connecions managers does not return contacts, as example Ring telephony contact manager does not. Gabble for Googletalk or Spirit for Skype does + * return contacts- + * + * \param id Contact address/id, as example email address, telephone number etc. Only exact matches + * \return TpContactPtr, if nontact is not returned TpContactPtr.isNull() is true + */ + Tp::ContactPtr TpSessionAccount::getContactFromAddress(QString id) { Tp::ContactPtr p; @@ -100,6 +148,13 @@ Tp::ContactPtr TpSessionAccount::getContactFromAddress(QString id) } return p; } +/** + * Fetch TpSessionChannel for with given address. Contact is searched among active channels for this account. + * + * + * \param id Contact address/id, as example email address, telephone number etc. Only exact matches + * \return Pointer to TpSessionChannel or NULL if nit found + */ TpSessionChannel* TpSessionAccount::getChannelFromPeerAddress(QString id) { @@ -109,6 +164,11 @@ TpSessionChannel* TpSessionAccount::getChannelFromPeerAddress(QString id) } return p; } +/** + * Creates new contact with given address. This function is Acynchronous, it sends request to contact manager for contact creation, + * + * \param address Contact address/id, as example email address, telephone number etc. + */ void TpSessionAccount::makeContactFromAddress(QString address) { @@ -131,6 +191,18 @@ void TpSessionAccount::onNewContactRetrieved(Tp::PendingOperation *op) qDebug() << "TpSessionAccount::onContactRetrieved" << reqContact; if(!reqContact.isEmpty()) addOutgoingChannel(contacts.first()); } +/** + * Send message to given address. This function is compled Acynchronous function that may produce multiple state transitions beforecomletion. + * If there is already existing TpSessionChannel for this contact, it simply queues message for sending and no forther transitions are needed + * If there are no hannel, it first check is there contact for this address, if is, it requests new channel to be created for ths channel and message + * is left waiting untill channel is created. If there is no contact, it sends request fr contact creation and when contact is created state machine + * proceeds to channel creation. + * + * MessageSent() signal is emitted when completed + * + * \param address Contact address/id, as example email address, telephone number etc. + * \param message Message string + */ void TpSessionAccount::sendMessageToAddress(QString address,QString message) { @@ -175,6 +247,7 @@ void TpSessionAccount::onOutgoingChannelReady(TpSessionChannel *ch) void TpSessionAccount::onMessageSent(const Tp::Message &msg,Tp::MessageSendingFlags, const QString &flags) { qDebug() << "TpSessionAccount::onMessageSent"; + emit messageSent(msg,this); }; void TpSessionAccount::onMessageReceived(const Tp::ReceivedMessage &msg,TpSessionChannel *ch) @@ -190,19 +263,23 @@ void TpSessionAccount::onNewChannels(const Tp::ChannelDetailsList &channels) qDebug() << "TpSessionAccount::onNewChannels"; foreach (const Tp::ChannelDetails &details, channels) { QString channelType = details.properties.value(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType")).toString(); + QString targetId = details.properties.value(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetID")).toString(); bool requested = details.properties.value(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".Requested")).toBool(); - qDebug() << " channelType:" << channelType; - qDebug() << " requested :" << requested; + qDebug() << " channelType:" << channelType <<" requested :" << requested << " targetId" << targetId; + emit newChannel(this,channelType,targetId,details); if (channelType == TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT && !requested) { - myIngoingTextChannel = Tp::TextChannel::create(acc->connection(),details.channel.path(),details.properties); - qDebug() << "TpSessionAccount::onNewChannels path=" <<"path " << myIngoingTextChannel->objectPath(); + myIngoingTextChannel = Tp::TextChannel::create(acc->connection(),details.channel.path(),details.properties); + qDebug() << "TpSessionAccount::onNewChannels path=" <<"path " << myIngoingTextChannel->objectPath(); - TpSessionChannel* newChannel=new TpSessionChannel( myIngoingTextChannel); - connect(newChannel,SIGNAL(messageReceived(const Tp::ReceivedMessage &,TpSessionChannel *)), + TpSessionChannel* newChannel=new TpSessionChannel( myIngoingTextChannel); + connect(newChannel,SIGNAL(messageReceived(const Tp::ReceivedMessage &,TpSessionChannel *)), SLOT(onMessageReceived(const Tp::ReceivedMessage &,TpSessionChannel *))); - myChannels+=newChannel; - } + myChannels+=newChannel; + } + if (channelType == TELEPATHY_INTERFACE_CHANNEL_TYPE_STREAMED_MEDIA && !requested) { + qDebug() << "Incoming call" ; + } } }