Esempio n. 1
0
Poco::SharedPtr<MessageData> Util::dataFromMessage(const MessageRef &message)
{
    int messageType = message->GetProp(Message::P_TYPE).toInt();

    SEString author;
    SEString authorName;
    SEString bodyXmlString;
    unsigned int timeStamp;
    message->GetPropAuthor(author);
    message->GetPropAuthorDisplayname(authorName);
    message->GetPropBodyXml(bodyXmlString);
    message->GetPropTimestamp(timeStamp);

    Poco::SharedPtr<MessageData> data = new MessageData;
    data->author = author.data();
    data->authorDisplayname = authorName.data();
    data->body = bodyXmlString.data();
    data->timestamp = timeStamp;
    data->isEmote = (messageType == Message::POSTED_EMOTE);

    return data;
}
Esempio n. 2
0
void SkypeContact::OnChange(int prop)
{
    /* Here is the place where you can capture all property changes when they
     * happen. It's important to know that this method will receive ALL changes
     * from ALL properties, which means that it's necessary to create a nice and
     * robust filter inside this method to handle each type of property,
     * otherwise it can fail by acting incorrectly or even lose some events.
     *
     * Another interesting thing is that this method does not receive the new
     * value of the changed property. It's necessary to get the value from the
     * Contact class itself, because once this method is called the property is
     * already changed in the class.
     */

    /* For our Contact class we will ony watch for the following
     * properties:
     *
     * - Contact::P_AVAILABILITY : Changes when the online status is set.
     * - Contact::P_DISPLAYNAME  : Changes when a new Display Name is set.
     * - Contact::P_SKYPENAME    : Changes when the skypename is updated.
     */
    if (prop == Contact::P_AVAILABILITY ||
        prop == Contact::P_DISPLAYNAME ||
        prop == Contact::P_SKYPENAME) {

        // Let's log that it has changed!
        SEString skypeName;
        GetPropSkypename(skypeName);

        printf("%s: Contact's property changed.\n", skypeName.data());

        /* And then notify the other interested objects that some of these
         * properties have changed.
         */
        ContactRef ref = this->ref();
        contactChanged(this, ref);
    }
}
Esempio n. 3
0
const Poco::SharedPtr<ContactData>
    Util::dataFromAccount(const AccountRef &account)
{
    Poco::SharedPtr<ContactData> data(0);

    data = Poco::SharedPtr<ContactData>(new ContactData);

    SEString value;

    // Get the Skype Name from the account.
    account->GetPropSkypename(value);
    data->skypeName = value.data();

    // Get the Display Name from the account.
    account->GetPropFullname(value);
    data->displayName = value;

    /* Get the availability from the Account and translate it to a readable
     * string.
     */
    Contact::AVAILABILITY availability;
    account->GetPropAvailability(availability);
    std::pair<ContactAvailability, std::string> ret =
        convertAvailability(availability);
    data->status = ret.first;
    data->availability = ret.second;

    //Get the contact Avatar.
    SEBinary rawData;

    if (account->GetPropAvatarImage(rawData) &&
        rawData.size() > 0)
        data->avatar.assignRaw(rawData.data(), rawData.size());

    return data;
}
Esempio n. 4
0
void ConvManagerService::setParticipants(
    const std::vector<std::string> &participantSkypeNames)
{
    // Get the new participants.
    unsigned int newSkypeNamesSize = participantSkypeNames.size();
    std::vector<std::string> newSkypeNames = participantSkypeNames;

    // Get the current participants.
    ParticipantRefs currentSkypeNames;
    m_conversation->GetParticipants(currentSkypeNames,
            Conversation::OTHER_CONSUMERS);
    unsigned int currentSkypeNamesSize = currentSkypeNames.size();


    // Check which participant needs to be added to the conversation.
    SEStringList addSkypeNames;

    for (unsigned int i = 0; i < newSkypeNamesSize; ++i) {
        bool contain = false;

        for (unsigned int j = 0; j < currentSkypeNamesSize; ++j) {
            SEString oid;
            currentSkypeNames[j]->GetPropIdentity(oid);

            if (newSkypeNames[i] == oid.data()) {
                if (m_conversationMode == Call)
                    currentSkypeNames[j]->Ring();
                contain = true;
                break;
            }
        }

        if (!contain)
            addSkypeNames.append(SEString(newSkypeNames[i].c_str()));
    }


    // Check which participant needs to be removed from the conversation.
    ParticipantRefs remSkypeNames;

    for (unsigned int i = 0; i < currentSkypeNamesSize; ++i) {
        bool contain = false;

        for (unsigned int j = 0; j < newSkypeNamesSize; ++j) {
            SEString oid;
            currentSkypeNames[i]->GetPropIdentity(oid);

            if (oid.data() == newSkypeNames[j]) {
                contain = true;
                break;
            }
        }

        if (!contain)
            remSkypeNames.append(currentSkypeNames[i]);
    }

    SkypeConversation::Ref newConversation;

    Conversation::TYPE type;
    m_conversation->GetPropType(type);

    // Pass the skypename string into addConsumers
    if (type == Conversation::DIALOG) {
        if (m_conversation->SpawnConference(addSkypeNames, newConversation))
            printf("spawned conference from conversation\n");
        else
            printf("error spawning conference from conversation\n");
    }
    else {
        // Add new participants to the conference.
        if (m_conversation->AddConsumers(addSkypeNames))
            printf("added participants to conversation\n");
        else
            printf("error adding participants to conversation\n");

        // Remove old participants from the conference.
        unsigned int remSize = remSkypeNames.size();
        for (unsigned int i = 0; i < remSize; ++i) {
            SEString oid;
            remSkypeNames[i]->GetPropIdentity(oid);

            if (m_conversationMode == Chat) {
                if (!remSkypeNames[i]->Retire())
                    printf("error retiring participant form conversation\n");
            }
            else {
                if (!remSkypeNames[i]->Hangup())
                    printf("error removing participant form conversation\n");
            }
        }
    }
}
Esempio n. 5
0
std::string ConvManagerState::id() const
{
    SEString identity;
    m_conversation->GetPropIdentity(identity);
    return std::string("ConvManagerState_") + identity.data();
}