Example #1
0
void GroupWindow::changeSubjectAction()
{
    GroupSubjectWindow *groupSubjectWindow =
            new GroupSubjectWindow((Group *) contact, this);

    connect(groupSubjectWindow,SIGNAL(changeSubject(QString, QString)),
            Client::mainWin,SLOT(sendSetGroupSubjectFromChat(QString,QString)));

    groupSubjectWindow->setAttribute(Qt::WA_Maemo5StackedWindow);
    groupSubjectWindow->setAttribute(Qt::WA_DeleteOnClose);
    groupSubjectWindow->setWindowFlags(groupSubjectWindow->windowFlags() | Qt::Window);

    groupSubjectWindow->show();
}
Example #2
0
ChatWindow *MainWindow::createChatWindow(Contact& contact, bool show)
{
    // Just open one window at a time to avoid duplicates
    createWindowMutex.lock();

    ChatWindow *chat;

    QString jid = contact.jid;

    if (contact.type == Contact::TypeGroup)
        Utilities::logData("Group");
    else
        Utilities::logData("Contact");

    if (!chatWindowList.contains(jid))
    {
        Utilities::logData("There's no previous chat window");

        if (contact.type == Contact::TypeContact)
            chat = new ChatWindow(&contact,this);
        else
            chat = new GroupWindow((Group *)&contact,this);

        chatWindowList.insert(jid,chat);

        if (!lastContactsList.contains(jid))
        {
            // This is a new chat and it is not in the
            // open chats list

            // Create the open chats item
            ChatDisplayItem *item = new ChatDisplayItem(&contact);
            lastContactsList.insert(jid,item);
            model->appendRow(item);

            // Set the last line logged in the item
            FMessage msg = chat->lastMessage();
            item->updateData(msg);

            // Store this chat in the DB
            ConversationsDBEntry entry;
            entry.jid = jid;
            entry.muted = false;
            entry.muteExpireTimestamp = 0;
            chatsDB.createChat(entry);

            if (contact.type == Contact::TypeContact)
                emit subscribe(jid);
        }
        else
        {
            // This chat is in the open chats list

            // Configure mute settings
            ChatDisplayItem *item = lastContactsList.value(jid);
            if (item->muted)
                chat->setMute(item->muteExpireTimestamp);
        }

        chat->setAttribute(Qt::WA_DeleteOnClose);

        if (!show)
                Utilities::logData("Chat window will not be shown");
        if (show)
        {
            Utilities::logData("Showing chat window");
            qint64 startTime = QDateTime::currentMSecsSinceEpoch();
            chat->show();
            qint64 endTime = QDateTime::currentMSecsSinceEpoch() - startTime;
            Utilities::logData("Chat window showed " + QString::number(endTime) +
                               " milliseconds.");
        }

        connect(chat,SIGNAL(sendMessage(FMessage)),
                this,SLOT(sendMessageFromChat(FMessage)));

        connect(chat,SIGNAL(destroyed(QObject *)),
                this,SLOT(deleteChat(QObject *)));

        connect(chat,SIGNAL(mute(QString,bool,qint64)),
                this,SLOT(mute(QString,bool,qint64)));

        connect(chat,SIGNAL(blockOrUnblockContact(QString,bool)),
                this,SLOT(blockOrUnblockContact(QString,bool)));

        connect(chat,SIGNAL(photoRefresh(QString,QString,bool)),
                this,SLOT(requestPhotoRefresh(QString,QString,bool)));

        connect(chat,SIGNAL(requestStatus(QString)),
                this,SLOT(requestContactStatus(QString)));

        connect(chat,SIGNAL(voiceNotePlayed(FMessage)),
                this,SLOT(sendVoiceNotePlayed(FMessage)));

        if (contact.type == Contact::TypeGroup)
        {
            GroupWindow *groupChat = (GroupWindow *) chat;
            connect(groupChat,SIGNAL(changeSubject(QString,QString)),
                    this,SLOT(sendSetGroupSubjectFromChat(QString,QString)));

            connect(groupChat,SIGNAL(requestLeaveGroup(QString)),
                    this,SLOT(requestLeaveGroupFromChat(QString)));

            connect(groupChat,SIGNAL(getParticipants(QString)),
                    this,SLOT(requestGetParticipants(QString)));
        }
        else
            emit queryLastOnline(jid);
    }