コード例 #1
0
ファイル: kmessagejabber.cpp プロジェクト: KDE/ksirk
KMessageJabber::KMessageJabber (const QString& peerJid, JabberClient* jabberClient, QObject *parent)
  : KMessageIO (parent),
  mClient(jabberClient),
  mPeerJid(peerJid)
{
  kDebug() << peerJid;
//   initSocket ();
  connect(jabberClient, SIGNAL(messageReceived(XMPP::Message)), this, SLOT(slotMessageReceived(XMPP::Message)));
         
  connect(jabberClient, SIGNAL(resourceUnavailable(Jid,Resource)), this, SLOT(slotResourceUnavailable(Jid,Resource)));
                  
  connect(jabberClient, SIGNAL(groupChatLeft(XMPP::Jid)), this, SLOT(slotGroupChatLeft(XMPP::Message)));

  connect(jabberClient, SIGNAL(groupChatPresence(XMPP::Jid,XMPP::Status)), this, SLOT(slotGroupChatPresence(XMPP::Jid,XMPP::Status)));

  
  
}
コード例 #2
0
ファイル: FrmGroupChat.cpp プロジェクト: anchowee/rabbitim
bool CFrmGroupChat::Join(const QString &jid)
{
    if(jid.isEmpty())
        return false;

    QList<QXmppMucRoom*> rooms = CGlobal::Instance()->GetXmppClient()->m_MucManager.rooms();
    QXmppMucRoom* r;
    foreach(r, rooms)
    {
        if(r->jid() == jid)
        {
            LOG_MODEL_DEBUG("Group chat", "had joined room[%s]", qPrintable(jid));
            return false;
        }
    }

    m_pRoom = CGlobal::Instance()->GetXmppClient()->m_MucManager.addRoom(jid);
    if(m_pRoom)
    {
        bool check = connect(m_pRoom, SIGNAL(joined()),
                             SLOT(slotJoined()));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(left()),
                        SLOT(slotLeft()));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(nameChanged(QString)), 
                        SLOT(slotNameChanged(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(error(QXmppStanza::Error)),
                        SLOT(slotError(QXmppStanza::Error)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(subjectChanged(QString)),
                        SLOT(slotSubjectChanged(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(messageReceived(QXmppMessage)),
                        SLOT(slotMessageReceived(QXmppMessage)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(participantAdded(QString)),
                        SLOT(slotParticipantAdded(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(participantChanged(QString)),
                        SLOT(slotParticipantChanged(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(participantRemoved(QString)),
                        SLOT(slotParticipantRemoved(QString)));
        Q_ASSERT(check);
        
        check = connect(m_pRoom, SIGNAL(permissionsReceived(QList<QXmppMucItem>)),
                        SLOT(slotPermissionsReceived(QList<QXmppMucItem>)));
        Q_ASSERT(check);
 
        check = connect(m_pRoom, SIGNAL(configurationReceived(QXmppDataForm)),
                        SLOT(slotConfigurationReceived(QXmppDataForm)));
        Q_ASSERT(check);

        //设置昵称  
        m_pRoom->setNickName(CGlobal::Instance()->GetRoster()->Name());
        //加入房间  
        return m_pRoom->join();
    }
    return false;
}
コード例 #3
0
ファイル: chatclient.cpp プロジェクト: pva701/codes
ChatClient::ChatClient(ClientSocket *sockett, const QString& strHost, int nPort, int userIdx, const QString& pseud, QWidget *pwig):QWidget(pwig),
    userlist(new UserListWidget()), dialogFindFriends(NULL) {
    qDebug() << "chat client\n";
    pSocket = sockett;

    myId = userIdx;
    pseudonym = pseud;
    //infoAboutFriend = NULL;

    dialogFindFriends = new DialogFindFriends(this);
    connect(dialogFindFriends, SIGNAL(findFriend(QString)), this, SLOT(slotFindFriend(QString)));
    connect(dialogFindFriends, SIGNAL(add(User*)), this, SLOT(slotAddFriend(User*)));
    connect(dialogFindFriends, SIGNAL(write(User*)), this, SLOT(slotWriteToFriend(User*)));

    setWindowTitle("FriendlyChatClient");

    pButSend = new QPushButton("&Send", this);
    pButFind = new QPushButton("Find friends", this);

    QRect sizeOfMonitor = QApplication::desktop()->screenGeometry();
    qDebug() << "MONITOR " << sizeOfMonitor;
    setGeometry(sizeOfMonitor);

    QVBoxLayout *lytVBox = new QVBoxLayout();
    QHBoxLayout *lytHBox = new QHBoxLayout();
    QHBoxLayout *lytHButtonBox = new QHBoxLayout();

    tbwDialogs = new QTabWidget();///
    lytVBox->addWidget(tbwDialogs);

    lytHButtonBox->addWidget(pButSend);
    lytHButtonBox->addWidget(pButFind);

    lytVBox->addLayout(lytHButtonBox);
    pButSend->setMaximumSize(50, 40);
    pButSend->setEnabled(false);
    pButFind->setMaximumSize(100, 40);

    //listOfFriends->setIconSize(QSize(48, 48));
    userlist->setSelectionMode(QAbstractItemView::SingleSelection);
    QVector <User*> uss = pSocket->loadUserlist(myId);
    userlist->add(uss);
    for (int i = 0; i < uss.size(); ++i)
        connect(uss[i], SIGNAL(readMessages()), this, SLOT(slotReadMessageNotify()));
    notifs = Notification::convert(pSocket->loadNotifys(myId));

    connect(userlist, SIGNAL(doubleClickUser(Dialog*)), this, SLOT(slotDoubleClickDialog(Dialog*)));
    //pItem1->setBackgroundColor(QColor(255, 0, 0));
    //pItem1->setFlags(Qt::ItemIsDragEnabled | Qt::ItemIsEnabled | Qt::ItemIsSelectable);

    lytHBox->addLayout(lytVBox, 2);
    lytHBox->addWidget(userlist);
    setLayout(lytHBox);
    tbwDialogs->setMovable(true);
    tbwDialogs->setTabsClosable(true);
    connect(tbwDialogs, SIGNAL(tabCloseRequested(int)), this, SLOT(slotTabClosed(int)));
    connect(tbwDialogs, SIGNAL(currentChanged(int)), this, SLOT(slotCurrentTabChanged(int)));

    connect(pButSend, SIGNAL(clicked()), this, SLOT(slotPrepareSendMessage()));
    connect(pButFind, SIGNAL(clicked()), this, SLOT(slotFindFriendsOpen()));
    //connect(listener, SIGNAL(messageRecieved(quint16,quint16,QDateTime,QString)), this, SLOT(slotMessageRecieved(quint16,quint16,QDateTime,QString)));
    connect(pSocket->listener(), SIGNAL(messageReceived(quint16,quint16,QDateTime,QString)), this, SLOT(slotMessageReceived(quint16,quint16,QDateTime,QString)), Qt::QueuedConnection);
    connect(pSocket->listener(), SIGNAL(youAddedInUserlist(quint16, QString)), this, SLOT(slotYouAreAddedInUserlist(quint16, QString)), Qt::QueuedConnection);
    connect(pSocket->listener(), SIGNAL(notifyOnOff(quint16,bool)), this, SLOT(slotNotifyOnOff(quint16, bool)));
    connect(pSocket->socket(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(slotError(QAbstractSocket::SocketError)));
    connect(pSocket->listener(), SIGNAL(readAllYouMessageNotify(int)), SLOT(slotReadAllYouMessageNotify(int)));

    pSocket->initDateTime();
    showNotifications();
}