void MessageCarbons::stanzaRequestResult(const Jid &AStreamJid, const Stanza &AStanza) { if (AStanza.type() == "result") { if (FEnableRequests.contains(AStanza.id())) { LogDetaile(QString("[MessageCarbons] Message Carbons enabled for '%1'").arg(AStreamJid.full())); FEnabled[AStreamJid] = true; emit enableChanged(AStreamJid,true); } else if(FDisableRequests.contains(AStanza.id())) { LogDetaile(QString("[MessageCarbons] Message Carbons disabled for '%1'").arg(AStreamJid.full())); FEnabled[AStreamJid] = false; emit enableChanged(AStreamJid,false); } } else { ErrorHandler err(AStanza.element()); LogError(QString("[MessageCarbons] Failed to change Message Carbons state for '%1': %2").arg(AStreamJid.full(),err.message())); emit errorReceived(AStreamJid,err.condition(),err.message()); } FEnableRequests.removeAll(AStanza.id()); FDisableRequests.removeAll(AStanza.id()); }
void ProcessMuc::initMuc( const std::string &jid, const std::string &password, ResourceContextRef rc) { Jid roomNode; roomNode.setJid(jid); //1. group MucGroup::ref roomGrp; roomGrp=boost::dynamic_pointer_cast<MucGroup> (rc->roster->findGroup(roomNode.getBareJid())); if (!roomGrp) { roomGrp=MucGroup::ref(new MucGroup(roomNode.getBareJid(), roomNode.getUserName())); rc->roster->addGroup(roomGrp); } roomGrp->password=password; //2. room contact MucRoom::ref room=roomGrp->room; if (!room) { room=MucRoom::ref(new MucRoom(jid)); roomGrp->room=room; room->group=roomGrp->getName(); } rosterWnd->openChat(room); //3. selfcontact roomGrp->selfContact=getMucContactEntry(jid, rc); }
bool Annotations::setAnnotation(const Jid &AStreamJid, const Jid &AContactJid, const QString &ANote) { if (isEnabled(AStreamJid)) { if (!ANote.isEmpty()) { Annotation &item = FAnnotations[AStreamJid][AContactJid.bare()]; item.modified = DateTime(QDateTime::currentDateTime()); if (!item.created.isValid()) item.created = item.modified; item.note = ANote; } else { FAnnotations[AStreamJid].remove(AContactJid.bare()); } updateDataHolder(AStreamJid,QList<Jid>()<<AContactJid); emit annotationModified(AStreamJid,AContactJid); FSavePendingStreams += AStreamJid; FSaveTimer.start(); return true; } else { LOG_STRM_WARNING(AStreamJid,QString("Failed to set annotation to=%1: Annotations is not enabled").arg(AContactJid.bare())); } return false; }
UserStatus userStatusFor(const Jid& jid, QList<UserListItem*> ul, bool forceEmptyResource) { if (ul.isEmpty()) return UserStatus(); UserStatus u; u.userListItem = ul.first(); if (jid.resource().isEmpty() || forceEmptyResource) { // use priority if (u.userListItem->isAvailable()) { const UserResource &r = *u.userListItem->userResourceList().priority(); u.statusType = r.status().type(); u.status = r.status().status(); u.publicKeyID = r.publicKeyID(); } } else { // use specific UserResourceList::ConstIterator rit = u.userListItem->userResourceList().find(jid.resource()); if (rit != u.userListItem->userResourceList().end()) { u.statusType = (*rit).status().type(); u.status = (*rit).status().status(); u.publicKeyID = (*rit).publicKeyID(); } } if (u.statusType == XMPP::Status::Offline) u.status = u.userListItem->lastUnavailableStatus().status(); return u; }
void ChangePasswordDlg::apply() { // sanity check if(ui_.le_pwcur->text().isEmpty() || ui_.le_pwnew->text().isEmpty() || ui_.le_pwver->text().isEmpty()) { QMessageBox::information(this, tr("Error"), tr("You must fill out the fields properly before you can proceed.")); return; } if(ui_.le_pwcur->text() != pa->userAccount().pass) { QMessageBox::information(this, tr("Error"), tr("You entered your old password incorrectly. Try again.")); ui_.le_pwcur->setText(""); ui_.le_pwcur->setFocus(); return; } if(ui_.le_pwnew->text() != ui_.le_pwver->text()) { QMessageBox::information(this, tr("Error"), tr("New password and confirmation do not match. Please enter them again.")); ui_.le_pwnew->setText(""); ui_.le_pwver->setText(""); ui_.le_pwnew->setFocus(); return; } ui_.busy->start(); blockWidgets(); JT_Register *reg = new JT_Register(pa->client()->rootTask()); connect(reg, SIGNAL(finished()), SLOT(finished())); Jid j = pa->userAccount().jid; reg->reg(j.node(), ui_.le_pwnew->text()); reg->go(true); }
FileTransferHandler::FileTransferHandler(PsiAccount *pa, FileTransfer *ft) { d = new Private; d->pa = pa; d->c = 0; if(ft) { d->sending = false; d->peer = ft->peer(); d->fileName = clean_filename(ft->fileName()); d->fileSize = ft->fileSize(); d->desc = ft->description(); d->shift = calcShift(d->fileSize); d->complement = calcComplement(d->fileSize, d->shift); d->ft = ft; Jid proxy = d->pa->userAccount().dtProxy; if(proxy.isValid()) d->ft->setProxy(proxy); mapSignals(); } else { d->sending = true; d->ft = 0; } }
void JingleVoiceCaller::call(const Jid& jid) { qDebug(QString("jinglevoicecaller.cpp: Calling %1").arg(jid.full())); cricket::Call *c = ((cricket::PhoneSessionClient*)(phone_client_))->CreateCall(); c->InitiateSession(buzz::Jid(jid.full().ascii())); phone_client_->SetFocus(c); }
void MUCJoinDlg::doJoin() { if(!d->pa || !d->pa->checkConnected(this)) return; QString host = le_host->text(); QString room = le_room->text(); QString nick = le_nick->text(); QString pass = le_pass->text(); if(host.isEmpty() || room.isEmpty() || nick.isEmpty()) { QMessageBox::information(this, tr("Error"), tr("You must fill out the fields in order to join.")); return; } Jid j = room + '@' + host + '/' + nick; if(!j.isValid()) { QMessageBox::information(this, tr("Error"), tr("You entered an invalid room name.")); return; } if(!d->pa->groupChatJoin(host, room, nick, pass, !ck_history->isChecked())) { QMessageBox::information(this, tr("Error"), tr("You are in or joining this room already!")); return; } d->psi->dialogUnregister(this); d->jid = room + '@' + host + '/' + nick; d->pa->dialogRegister(this, d->jid); disableWidgets(); d->busy->start(); }
bool MultiUserChat::sendMessage(const Message &AMessage, const QString &AToNick) { if (isOpen()) { Jid toJid = FRoomJid; toJid.setResource(AToNick); Message message = AMessage; message.setTo(toJid.full()); message.setType(AToNick.isEmpty() ? Message::GroupChat : Message::Chat); if (FMessageProcessor) { if (FMessageProcessor->sendMessage(FStreamJid,message,IMessageProcessor::DirectionOut)) return true; else LOG_STRM_WARNING(FStreamJid,QString("Failed to send message to conference, room=%1").arg(FRoomJid.bare())); } else if (FStanzaProcessor) { if (FStanzaProcessor->sendStanzaOut(FStreamJid, message.stanza())) { emit messageSent(message); return true; } else { LOG_STRM_WARNING(FStreamJid,QString("Failed to send message to conference, room=%1").arg(FRoomJid.bare())); } } } return false; }
bool SASLBind::xmppStanzaIn(IXmppStream *AXmppStream, Stanza &AStanza, int AOrder) { if (AXmppStream==FXmppStream && AOrder==XSHO_XMPP_FEATURE && AStanza.id()=="bind") { FXmppStream->removeXmppStanzaHandler(this, XSHO_XMPP_FEATURE); if (AStanza.type() == "result") { Jid streamJid = AStanza.firstElement().firstChild().toElement().text(); if (streamJid.isValid()) { LogDetaile(QString("[SASLBind][%1] XMPP session binded with resource='%2'").arg(FXmppStream->streamJid().bare()).arg(streamJid.resource())); deleteLater(); FXmppStream->setStreamJid(streamJid); emit finished(false); } else { LogError(QString("[SASLBind][%1] Invalid XMPP stream JID in response").arg(FXmppStream->streamJid().bare())); emit error(tr("Invalid XMPP stream JID in SASL bind response")); } } else { ErrorHandler err(AStanza.element()); LogError(QString("[SASLBind] Failed to bind XMPP session: %1").arg(err.message())); emit error(err.message()); } return true; } return false; }
bool FileWriter::writeMessage(const Message &AMessage, const QString &ASaveMode, bool ADirectionIn) { if (isOpened() && ASaveMode!=ARCHIVE_SAVE_FALSE) { Jid contactJid = AMessage.from(); FGroupchat |= AMessage.type()==Message::GroupChat; if (!FGroupchat || contactJid.hasResource()) { FMessagesCount++; FXmlWriter->writeStartElement(ADirectionIn ? "from" : "to"); int secs = FHeader.start.secsTo(AMessage.dateTime()); if (secs >= 0) FXmlWriter->writeAttribute("secs",QString::number(secs)); else FXmlWriter->writeAttribute("utc",DateTime(AMessage.dateTime()).toX85UTC()); if (FGroupchat) FXmlWriter->writeAttribute("name",contactJid.resource()); if (ASaveMode == ARCHIVE_SAVE_BODY) FXmlWriter->writeTextElement("body",AMessage.body()); else writeElementChilds(AMessage.stanza().element()); FXmlWriter->writeEndElement(); FXmlFile->flush(); checkLimits(); return true; } } return false; }
void Client::updateSelfPresence(const Jid &j, const Status &s) { ResourceList::Iterator rit = d->resourceList.find(j.resource()); bool found = (rit == d->resourceList.end()) ? false: true; // unavailable? remove the resource if(!s.isAvailable()) { if(found) { debug(QString("Client: Removing self resource: name=[%1]\n").arg(j.resource())); (*rit).setStatus(s); resourceUnavailable(j, *rit); d->resourceList.remove(rit); } } // available? add/update the resource else { Resource r; if(!found) { r = Resource(j.resource(), s); d->resourceList += r; debug(QString("Client: Adding self resource: name=[%1]\n").arg(j.resource())); } else { (*rit).setStatus(s); r = *rit; debug(QString("Client: Updating self resource: name=[%1]\n").arg(j.resource())); } resourceAvailable(j, r); } }
void Client::updatePresence(LiveRosterItem *i, const Jid &j, const Status &s) { ResourceList::Iterator rit = i->resourceList().find(j.resource()); bool found = (rit == i->resourceList().end()) ? false: true; // unavailable? remove the resource if(!s.isAvailable()) { if(found) { (*rit).setStatus(s); debug(QString("Client: Removing resource from [%1]: name=[%2]\n").arg(i->jid().full()).arg(j.resource())); resourceUnavailable(j, *rit); i->resourceList().remove(rit); i->setLastUnavailableStatus(s); } } // available? add/update the resource else { Resource r; if(!found) { r = Resource(j.resource(), s); i->resourceList() += r; debug(QString("Client: Adding resource to [%1]: name=[%2]\n").arg(i->jid().full()).arg(j.resource())); } else { (*rit).setStatus(s); r = *rit; debug(QString("Client: Updating resource to [%1]: name=[%2]\n").arg(i->jid().full()).arg(j.resource())); } resourceAvailable(j, r); } }
QString ExchangeApproveDialog::contactName(const Jid &AContactJid, bool AWithJid) const { IRosterItem ritem = FRoster->findItem(AContactJid); QString name = !ritem.name.isEmpty() ? ritem.name : AContactJid.uBare(); if (AWithJid && !ritem.name.isEmpty()) name = QString("%1 <%2>").arg(name,AContactJid.uBare()); return name; }
void JingleVoiceCaller::reject(const Jid& j) { qDebug("jinglevoicecaller.cpp: Rejecting call"); cricket::Call* call = calls_[j.full()]; if (call != NULL) { call->RejectSession(call->sessions()[0]); calls_.remove(j.full()); } }
void JingleVoiceCaller::terminate(const Jid& j) { qDebug(QString("jinglevoicecaller.cpp: Terminating call to %1").arg(j.full())); cricket::Call* call = calls_[j.full()]; if (call != NULL) { call->Terminate(); calls_.remove(j.full()); } }
bool Stanza::isFromServer() const { if (!to().isEmpty()) { Jid toJid = to(); Jid fromJid = from(); return fromJid.isEmpty() || fromJid==toJid || fromJid==toJid.bare() || fromJid==toJid.domain(); } return false; }
QString JIDUtil::accountToString(const Jid& j, bool withResource) { QString s = j.node(); // if (!defaultDomain().isEmpty()) { // return (withResource && !j.resource().isEmpty() ? j.node() + "/" + j.resource() : j.node()); // } // else { return (withResource ? j.full() : j.bare()); //} }
bool Roster::stanzaReadWrite(int AHandlerId, const Jid &AStreamJid, Stanza &AStanza, bool &AAccept) { if (AHandlerId == FSHIRosterPush) { if (isOpen() && AStanza.isFromServer()) { AAccept = true; LOG_STRM_DEBUG(streamJid(),"Roster items push received"); processItemsElement(AStanza.firstElement("query",NS_JABBER_ROSTER),false); Stanza result = FStanzaProcessor->makeReplyResult(AStanza); FStanzaProcessor->sendStanzaOut(AStreamJid,result); } else if (!isOpen()) { REPORT_ERROR("Failed to process roster items push: Roster is closed"); } else if (!AStanza.isFromServer()) { REPORT_ERROR("Failed to process roster items push: Invalid stanza sender"); } } else if (AHandlerId == FSHISubscription) { Jid contactJid = AStanza.from(); QString status = AStanza.firstElement("status").text(); if (AStanza.type() == SUBSCRIPTION_SUBSCRIBE) { AAccept = true; FSubscriptionRequests += contactJid.bare(); LOG_STRM_INFO(streamJid(),QString("Subscribe presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Subscribe,status); } else if (AStanza.type() == SUBSCRIPTION_SUBSCRIBED) { AAccept = true; LOG_STRM_INFO(streamJid(),QString("Subscribed presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Subscribed,status); } else if (AStanza.type() == SUBSCRIPTION_UNSUBSCRIBE) { AAccept = true; FSubscriptionRequests -= contactJid.bare(); LOG_STRM_INFO(streamJid(),QString("Unsubscribe presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Unsubscribe,status); } else if (AStanza.type() == SUBSCRIPTION_UNSUBSCRIBED) { AAccept = true; LOG_STRM_INFO(streamJid(),QString("Unsubscribed presence received from=%1, status=%2").arg(contactJid.full(),status)); emit subscriptionReceived(AStanza.from(),IRoster::Unsubscribed,status); } } return false; }
bool MultiUserChat::isUserPresent(const Jid &AContactJid) const { if (FUsers.contains(AContactJid.resource()) && AContactJid.pBare()==FRoomJid.pBare()) return true; foreach(MultiUser *user, FUsers) if (AContactJid == user->data(MUDR_REAL_JID).toString()) return true; return false; }
void JingleVoiceCaller::registerCall(const Jid& jid, cricket::Call* call) { qDebug("jinglevoicecaller.cpp: Registering call\n"); if (!calls_.contains(jid.full())) { calls_[jid.full()] = call; } else { qWarning("jinglevoicecaller.cpp: Auto-rejecting call because another call is currently open"); call->RejectSession(call->sessions()[0]); } }
void JingleVoiceCaller::registerCall(const Jid& jid, cricket::Call* call) { qDebug("jinglevoicecaller.cpp: Registering call\n"); kdDebug(14000) << k_funcinfo << jid.full() << endl; if (!calls_.contains(jid.full())) { calls_[jid.full()] = call; } // else { // qWarning("jinglevoicecaller.cpp: Auto-rejecting call because another call is currently open"); // call->RejectSession(call->sessions()[0]); // } }
void NewPoi::initStreamList(const QString &ABareJid, bool AEditable) { if (FAccounts) { Jid streamJid; if (!ABareJid.isEmpty()) streamJid=FPoi->findStreamJid(ABareJid); for (QList<IAccount *>::const_iterator it=FAccounts->constBegin(); it!=FAccounts->constEnd(); it++) ui->boxAccount->addItem((*it)->name(), QVariant((*it)->streamJid().full())); ui->boxAccount->setCurrentIndex(streamJid.isValid()?ui->boxAccount->findData(QVariant(streamJid.full())):0); } ui->boxAccount->setEnabled(AEditable); }
bool MultiUserChat::stanzaReadWrite(int AHandlerId, const Jid &AStreamJid, Stanza &AStanza, bool &AAccept) { Jid fromJid = AStanza.from(); if (AStreamJid==FStreamJid && FRoomJid.pBare()==fromJid.pBare()) { AAccept = true; if (AHandlerId == FSHIPresence) processPresence(AStanza); else if (AHandlerId == FSHIMessage) processMessage(AStanza); return true; } return false; }
void JT_Register::unreg(const Jid &j) { d->type = 2; to = j.isEmpty() ? client()->host() : j.full(); iq = createIQ(doc(), "set", to.full(), id()); QDomElement query = doc()->createElement("query"); query.setAttribute("xmlns", "jabber:iq:register"); iq.appendChild(query); // this may be useful if(!d->form.key().isEmpty()) query.appendChild(textTag(doc(), "key", d->form.key())); query.appendChild(doc()->createElement("remove")); }
/** * \brief Call this when you need to update vCard in cache. */ void VCardFactory::setVCard(const Jid &j, const VCard &v) { VCard *vcard = new VCard; *vcard = v; checkLimit(j.userHost(), vcard); emit vcardChanged(j); }
void JT_HTTPFileUpload::request(const Jid &to, const QString &fname, quint64 fsize, const QString &ftype, XEP0363::version ver) { d->to = to; d->ver = ver; d->iq = createIQ(doc(), "get", to.full(), id()); QDomElement req = doc()->createElement("request"); switch (ver) { case XEP0363::v0_2_5: req.setAttribute("xmlns", xmlns_v0_2_5); req.appendChild(textTag(doc(), "filename", fname)); req.appendChild(textTag(doc(), "size", QString::number(fsize))); if (!ftype.isEmpty()) { req.appendChild(textTag(doc(), "content-type", ftype)); } break; case XEP0363::v0_3_1: req.setAttribute("xmlns", xmlns_v0_3_1); req.setAttribute("filename", fname); req.setAttribute("size", fsize); if (!ftype.isEmpty()) req.setAttribute("content-type", ftype); break; default: d->ver = XEP0363::vUnknown; break; } d->iq.appendChild(req); }
VoiceCallDlg::VoiceCallDlg(const Jid& jid, VoiceCaller* voiceCaller) : QDialog(0), jid_(jid), voiceCaller_(voiceCaller) { setAttribute(Qt::WA_DeleteOnClose); ui_.setupUi(this); setModal(false); setWindowTitle(QString(tr("Voice Call (%1)")).arg(jid.full())); // Voice Caller signals connect(voiceCaller_,SIGNAL(accepted(const Jid&)),SLOT(accepted(const Jid&))); connect(voiceCaller_,SIGNAL(rejected(const Jid&)),SLOT(rejected(const Jid&))); connect(voiceCaller_,SIGNAL(in_progress(const Jid&)),SLOT(in_progress(const Jid&))); connect(voiceCaller_,SIGNAL(terminated(const Jid&)),SLOT(terminated(const Jid&))); // Buttons ui_.pb_hangup->setEnabled(false); ui_.pb_accept->setEnabled(false); ui_.pb_reject->setEnabled(false); connect(ui_.pb_hangup,SIGNAL(clicked()),SLOT(terminate_call())); connect(ui_.pb_accept,SIGNAL(clicked()),SLOT(accept_call())); connect(ui_.pb_reject,SIGNAL(clicked()),SLOT(reject_call())); }
EditBookmarksDialog::EditBookmarksDialog(IBookmarks *ABookmarks, const Jid &AStreamJid, const QList<IBookmark> &AList, QWidget *AParent) : QDialog(AParent) { REPORT_VIEW; ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose,true); setWindowTitle(tr("Edit bookmarks - %1").arg(AStreamJid.uBare())); IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_BOOKMARKS_EDIT,0,0,"windowIcon"); FBookmarks = ABookmarks; FStreamJid = AStreamJid; ui.tbwBookmarks->setRowCount(AList.count()); for (int row=0; row<AList.count(); ++row) { IBookmark bookmark = AList.at(row); setBookmarkToRow(row,bookmark); } QHeaderView *header = ui.tbwBookmarks->horizontalHeader(); header->setSectionsClickable(true); header->setSectionResizeMode(COL_NAME,QHeaderView::ResizeToContents); header->setSectionResizeMode(COL_VALUE,QHeaderView::Stretch); header->setSectionResizeMode(COL_NICK,QHeaderView::ResizeToContents); header->hideSection(COL_SORT); connect(header,SIGNAL(sectionClicked(int)),SLOT(onSortingStateChange(int))); connect(ui.pbtAdd,SIGNAL(clicked()),SLOT(onEditButtonClicked())); connect(ui.pbtEdit,SIGNAL(clicked()),SLOT(onEditButtonClicked())); connect(ui.pbtDelete,SIGNAL(clicked()),SLOT(onEditButtonClicked())); connect(ui.pbtMoveUp,SIGNAL(clicked()),SLOT(onEditButtonClicked())); connect(ui.pbtMoveDown,SIGNAL(clicked()),SLOT(onEditButtonClicked())); connect(ui.bbxButtons,SIGNAL(accepted()),SLOT(onDialogAccepted())); connect(ui.tbwBookmarks,SIGNAL(itemDoubleClicked(QTableWidgetItem *)),SLOT(onTableItemDoubleClicked(QTableWidgetItem *))); }
SubscriptionDialog::SubscriptionDialog(IRosterChanger *ARosterChanger, const Jid &AStreamJid, const Jid &AContactJid, const QString &ANotify, const QString &AMessage, QWidget *AParent) : QDialog(AParent) { REPORT_VIEW; ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose,true); setWindowTitle(tr("Subscription request - %1").arg(AStreamJid.uBare())); IconStorage::staticStorage(RSR_STORAGE_MENUICONS)->insertAutoIcon(this,MNI_RCHANGER_SUBSCRIBTION,0,0,"windowIcon"); FStreamJid = AStreamJid; FContactJid = AContactJid; FRosterChanger = ARosterChanger; QToolBar *toolBar = new QToolBar(this); toolBar->setIconSize(QSize(16,16)); ui.lytMainLayout->setMenuBar(toolBar); FToolBarChanger = new ToolBarChanger(toolBar); ui.lblNotify->setText(ANotify); if (!AMessage.isEmpty()) ui.lblMessage->setText(AMessage); else ui.lblMessage->setVisible(false); connect(ui.btbDialogButtons,SIGNAL(accepted()),SLOT(onDialogAccepted())); connect(ui.btbDialogButtons,SIGNAL(rejected()),SLOT(onDialogRejected())); initialize(); }