void gajim::loadMessages(const QString &path) { QDir dir = path; QFileInfo info(dir.filePath("logs.db")); if(!info.exists()) return; QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE"); db.setDatabaseName(info.absoluteFilePath()); if(!db.open()) return; setProtocol("jabber"); setAccount(m_account); QSqlQuery jid_query("SELECT jid_id, jid FROM jids", db); setMaxValue(jid_query.size()); int num = 0; while(jid_query.next()) { QString jid_id = jid_query.value(0).toString(); QString jid = jid_query.value(1).toString(); setContact(jid); static QString query_str = "SELECT time, message, kind FROM logs " "WHERE jid_id = %1 AND (kind = 4 OR kind = 6) " "ORDER BY time ASC"; QSqlQuery query(query_str.arg(jid_id), db); while(query.next()) { Message message; message.setTime(QDateTime::fromTime_t(query.value(0).toInt())); message.setIncoming(query.value(2).toInt() == 4); message.setText(query.value(1).toString()); appendMessage(message); } setValue(++num); } }
void andrq::loadMessages(const QString &path) { QDir dir = path; QString account = dir.dirName(); if(!dir.cd("history")) return; setProtocol("ICQ"); setAccount(account); QFileInfoList files = dir.entryInfoList(QDir::Files); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString uin = files[i].fileName(); QFile file(files[i].absoluteFilePath()); if(!file.open(QFile::ReadOnly)) continue; setContact(uin); QDataStream in(&file); in.setByteOrder(QDataStream::LittleEndian); Message message; message.type=1; while(!in.atEnd()) { qint32 type; in >> type; switch(type) { case -1: { quint8 kind; qint32 who; in >> kind >> who; QString from = QString::number(who); message.in = from == uin; message.time = getDateTime(in); qint32 tmp; in >> tmp; in.skipRawData(tmp); message.text = Qt::escape(getString(in, who)).replace("\n", "<br/>"); if(kind==1) appendMessage(message); break; } case -2: { qint32 tmp; in >> tmp; in.skipRawData(tmp); break; } case -3: in.skipRawData(5); break; default: break; } } } }
void GroupWindow::setGroup(Group *group, bool notify) { setContact(group); if (notify && group->subjectOwner != Client::myJid) QMaemo5InformationBox::information(this, Utilities::removeEmoji(group->subjectOwnerName) + " changed the subject to " + group->name); }
void BE::Contacts::closeEvent(QCloseEvent *) { setContact(QModelIndex()); // store current contact changes if (m_dirty) { if (QMessageBox::question(this, tr("Contacts"), tr("Save changes?"), QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { saveContacts(); } else { m_abook->model()->removeRows(0, m_abook->model()->rowCount()); m_abook->readAbook(false); } } }
void ContactWrapper::onContactManagerStateChanged(Tp::ContactListState newState) { if (newState == Tp::ContactListStateSuccess) { QList<Tp::ContactPtr> contactList = m_account->connection()->contactManager()->allKnownContacts().toList(); for (int i = 0; i < contactList.count(); ++i) { if (contactList.at(i)->id() == m_tempContactId) { setContact(contactList.at(i)); break; } } } }
void KeyhoteeMainWindow::createContactGui( int contact_id ) { //DLNFIX2 maybe cleanup/refactor ContactGui construction later auto new_contact_item = new QTreeWidgetItem(_contacts_root, (QTreeWidgetItem::ItemType)ContactItem ); new_contact_item->setData( 0, ContactIdRole, contact_id ); auto view = new ContactView( ui->widget_stack ); //add new contactGui to map ContactGui contact_gui(new_contact_item,view); _contact_guis[contact_id] = contact_gui; view->setAddressBook( _addressbook_model ); const Contact& contact = _addressbook_model->getContactById( contact_id ); view->setContact(contact); ui->widget_stack->addWidget( view ); }
void BE::Contacts::manageContact(const QString &mail, const QString &prettyName) { QStandardItemModel *model = m_abook->model(); for (int i = 0; i < model->rowCount(); ++i) { QStandardItem *item = model->item(i); if (QString::compare(item->data(Gui::AbookAddressbook::Mail).toString(), mail, Qt::CaseInsensitive) == 0) { setContact(model->index(i, 0)); return; } } // no match -> create one addContact(); m_ui2->mail->setText(mail); if (!prettyName.isEmpty()) { m_ui2->name->setText(prettyName); m_currentContact->setText(prettyName); } else { m_ui2->name->setText("[name]"); } }
void psi::loadMessages(const QString &path) { QDir dir = path; if(!dir.cd("history")) return; QFileInfoList files = dir.entryInfoList(QStringList() << "*.history", QDir::Files); setProtocol("jabber"); setAccount(m_account); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString contact = files[i].fileName(); contact.chop(4); contact = decode(contact); setContact(contact); QFile file(files[i].absoluteFilePath()); if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) continue; QTextStream in(&file); in.setCodec("utf-8"); while(!in.atEnd()) { static const QChar c('|'); QString line = in.readLine(); if(line.isEmpty()) continue; // |2008-07-13T15:27:57|5|from|N3--|Цитата #397796|http://bash.org.ru/quote/397796|Цитата #397796|xxx: cool text Message message; message.setTime(QDateTime::fromString(line.section(c, 1, 1), Qt::ISODate)); message.setIncoming(line.section(c, 3, 3) == "from"); QString text = line.mid(line.lastIndexOf(c) + 1); int psi_type = line.section(c, 2, 2).toInt(); if(psi_type == 2 || psi_type == 3 || psi_type == 6 || psi_type == 7 || psi_type == 8 || text.isEmpty()) continue; message.setText(logdecode(text)); appendMessage(message); } } }
ContactView::ContactView(QWidget* parent) : QWidget(parent), ui(new Ui::ContactView() ), _validForm(false) { _address_book = nullptr; ui->setupUi(this); _addingNewContact = false; _editing = false; _modified = false; message_tools = new QToolBar( ui->toolbar_container ); QGridLayout* grid_layout = new QGridLayout(ui->toolbar_container); grid_layout->setContentsMargins(0, 0, 0, 0); grid_layout->setSpacing(0); ui->toolbar_container->setLayout(grid_layout); grid_layout->addWidget(message_tools, 0, 0); ui->email->setVisible (false); //unsupported ui->phone->setVisible (false); ui->phone_label->setVisible (false); ui->email_label->setVisible (false); ui->privacy_comboBox->setVisible (false); ui->privacy_level_label->setVisible (false);//unsupported //default contact view: info page ui->contact_pages->setCurrentIndex(info); /// add identity observer IdentityObservable::getInstance().addObserver( ui->widget_Identity ); send_mail = new QAction( QIcon( ":/images/128x128/contact_info_send_mail.png"), tr("Mail"), this); chat_contact = new QAction( QIcon( ":/images/chat.png"), tr("Chat"), this); edit_contact = new QAction( QIcon(":/images/128x128/contact_info_edit.png"), tr("Edit"), this); share_contact = new QAction(QIcon(":/images/128x128/contact_share.png"), tr("Share contact"), this); request_contact = new QAction( QIcon(":/images/128x128/contact_info_request_authorisation.png"), tr("Request authorisation"), this); save_contact = new QAction( QIcon(":/images/128x128/contact_info_save.png"), tr( "Save"), this ); cancel_edit_contact = new QAction( QIcon(":/images/128x128/contact_info_cancel_edit.png"), tr("Discard changes"), this); connect(ui->icon_view, &QToolButton::clicked, this, &ContactView::onIconSearch); message_tools->addAction(send_mail); message_tools->addAction(chat_contact); message_tools->addAction(share_contact); message_tools->addAction(request_contact); separatorToolBar = message_tools->addSeparator (); message_tools->addAction(edit_contact); message_tools->addAction(save_contact); message_tools->addAction(cancel_edit_contact); QLabel *label = new QLabel((tr(" Create new contact"))); label_createContact = message_tools->addWidget (label); QFont font; font.setBold(true); font.setPointSize (16); label->setFont (font); ui->khid_pubkey->setMode(KeyhoteeIDPubKeyWidget::ModeWidget::ShowContact); connect(save_contact, &QAction::triggered, this, &ContactView::onSave); connect(cancel_edit_contact, &QAction::triggered, this, &ContactView::onCancel); connect(edit_contact, &QAction::triggered, this, &ContactView::onEdit); connect(send_mail, &QAction::triggered, this, &ContactView::onMail); connect(chat_contact, &QAction::triggered, this, &ContactView::onChat); connect(share_contact, &QAction::triggered, this, &ContactView::onShareContact); connect(request_contact, &QAction::triggered, this, &ContactView::onRequestContact); connect(ui->firstname, &QLineEdit::textChanged, this, &ContactView::firstNameChanged); connect(ui->lastname, &QLineEdit::textChanged, this, &ContactView::lastNameChanged); connect( ui->privacy_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(privacyLevelChanged(int))); connect(ui->email, &QLineEdit::textChanged, this, &ContactView::emailChanged); connect(ui->phone, &QLineEdit::textChanged, this, &ContactView::phoneChanged); connect(ui->notes, &QPlainTextEdit::textChanged, this, &ContactView::notesChanged); connect(ui->sendButton, &QPushButton::clicked, this, &ContactView::onSend); connect(ui->chat_input, &QPlainTextEdit::textChanged, this, &ContactView::onTextChanged); connect(ui->contact_pages, &QTabWidget::currentChanged, this, &ContactView::currentTabChanged); connect(ui->mining_effort_slider, &QSlider::valueChanged, this, &ContactView::onMiningEffortSliderChanged); connect(ui->khid_pubkey, &KeyhoteeIDPubKeyWidget::currentState, this, &ContactView::onStateWidget); contactEditable(false); ui->chat_input->installEventFilter(this); checkSendMailButton(); setContact(Contact() ); }
void qipinfium::loadMessages(const QString &path) { QDir dir = path; if(!dir.cd("History")) return; QHash<QString,QString> protocols; protocols[QLatin1String("icq")] = QLatin1String("ICQ"); protocols[QLatin1String("jabber")] = QLatin1String("Jabber"); protocols[QLatin1String("mra")] = QLatin1String("MRIM"); QStringList filters; foreach(QString format,protocols.keys()) filters << (format + QLatin1String("*.qhf")) << (format + QLatin1String("*.ahf")); QFileInfoList files = dir.entryInfoList(filters, QDir::Files); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString protocol = files[i].fileName().section("_",0,0); while(!protocol.isEmpty() && protocol.at(protocol.length() - 1).isDigit()) protocol.chop(1); protocol = protocols[protocol.toLower()]; if(protocol.isEmpty()) { warning() << "Unknown protocol: " << files[i].fileName(); continue; } setProtocol(protocol); setAccount(m_accounts.value(protocol)); QFile file(files[i].absoluteFilePath()); if(file.open(QFile::ReadOnly)) { QByteArray bytearray = file.readAll(); const uchar *data = (const uchar *)bytearray.constData(); const uchar *end = data + bytearray.size(); if(memcmp(data, "QHF", 3)) continue; uchar version = data[3]; data += 44; QString uin = getString(data, getUInt16(data)); QString name = getString(data, getUInt16(data)); Q_UNUSED(name); QDateTime time; setContact(uin); while(data < end) { quint16 type = getUInt16(data); quint32 index = getUInt32(data); data += 2; if(type == 1) { Message message; data += 10; time = QDateTime::fromTime_t(getUInt32(data)); time.setTimeSpec(Qt::LocalTime); if(version == 1) time = time.toUTC().addDays(2); else time = time.toUTC(); message.setTime(time); data += 4; message.setIncoming(getUInt8(data) == 0); data += 4; int mes_len = version == 3 ? getUInt32(data) : getUInt16(data); message.setText(getString(data, mes_len, version > 1)); appendMessage(message); } else data += index; } } } }
UtlBoolean SipSubscribeServer::handleSubscribe(const SipMessage& subscribeRequest) { UtlBoolean handledSubscribe = FALSE; UtlString eventName; subscribeRequest.getEventField(&eventName, NULL); // Not modifying the SubscribeServerEventData, just reading it lockForRead(); // Get the event specific handler and information SubscribeServerEventData* eventPackageInfo = dynamic_cast <SubscribeServerEventData*> (mEventDefinitions.find(&eventName)); // We handle this event type if (eventPackageInfo) { handledSubscribe = TRUE; SipSubscribeServerEventHandler* handler = eventPackageInfo->mpEventSpecificHandler; SipMessage subscribeResponse; // Check if authenticated (or if it needs to be authenticated) if (handler->isAuthenticated(subscribeRequest, subscribeResponse)) { // Check if authorized (or if authorization is required) if (handler->isAuthorized(subscribeRequest, subscribeResponse)) { // The subscription is allowed, so update the // subscription state. Set the To field tag if // this request initiated the dialog UtlString subscribeDialogHandle; UtlBoolean isNewDialog; UtlBoolean isExpiredSubscription; UtlString resourceId, eventTypeKey, eventType; eventPackageInfo->mpEventSpecificSubscriptionMgr-> updateDialogInfo( subscribeRequest, resourceId, eventTypeKey, eventType, subscribeDialogHandle, isNewDialog, isExpiredSubscription, subscribeResponse, // The event-specific handler provides a getKeys method // which is used to determine the resource ID // and event type if this is a new subscription. *handler); // Build a NOTIFY SipMessage notifyRequest; // Set the dialog information into the NOTIFY. // Note that the dialog can have ended by now, because of // a race condition with the processing of dialog-ending // messages from the outside world. if (eventPackageInfo->mpEventSpecificSubscriptionMgr-> getNotifyDialogInfo(subscribeDialogHandle, notifyRequest, "active;expires=%ld")) { // We still have record of the dialog, so the // NOTIFY headers were set. // Set the NOTIFY content UtlString acceptHeaderValue; if (!subscribeRequest.getAcceptField(acceptHeaderValue)) { // No Accept header seen, set special value allowing any // content type. acceptHeaderValue = SipPublishContentMgr::acceptAllTypes; } // Note that since this NOTIFY is due to a SUBSCRIBE, // it should contain 'full' content. Hence, // the fullState parameter of getNotifyContent is TRUE, // and is not taken from // eventPackageInfo->mEventSpecificFullState. UtlString availableMediaTypes; if (handler->getNotifyContent(resourceId, eventTypeKey, eventType, *(eventPackageInfo->mpEventSpecificContentMgr), acceptHeaderValue, notifyRequest, TRUE, &availableMediaTypes)) { // Update the NOTIFY content if required for this event type. // Sets 'version' and 'eventTypeKey'. int version; eventPackageInfo->mpEventSpecificSubscriptionMgr-> updateNotifyVersion(eventPackageInfo->mpEventSpecificContentVersionCallback, notifyRequest, version, eventTypeKey); // Update the saved record of the NOTIFY CSeq and the // XML version number for the specified eventTypeKey, // as needed by the subscription manager. // In practice, this is only used by SipPersistentSubscriptionMgr // to write the NOTIFY Cseq and XML version into the IMDB. eventPackageInfo->mpEventSpecificSubscriptionMgr-> updateVersion(notifyRequest, version, eventTypeKey); // Send the NOTIFY request setContact(¬ifyRequest); eventPackageInfo->mpEventSpecificUserAgent->send(notifyRequest); if (OsSysLog::willLog(FAC_SIP, PRI_INFO)) { UtlString requestContact; subscribeRequest.getContactField(0, requestContact); OsSysLog::add(FAC_SIP, PRI_INFO, "SipSubscribeServer::handleSubscribe: %s has setup subscription to %s, eventTypeKey %s", requestContact.data(), resourceId.data(), eventTypeKey.data()); } } else { // No content was available, so the subscription fails. // Determine the reason and set the response code. if (availableMediaTypes.isNull()) { // No MIME types are available, so the resource does not exist. subscribeResponse.setResponseFirstHeaderLine(SIP_PROTOCOL_VERSION, SIP_NOT_FOUND_CODE, SIP_NOT_FOUND_TEXT); } else { // MIME types are available, so the resource exists. subscribeResponse.setResponseFirstHeaderLine(SIP_PROTOCOL_VERSION, SIP_BAD_MEDIA_CODE, SIP_BAD_MEDIA_TEXT); subscribeResponse.setAcceptField(availableMediaTypes); } // Destroy the subscription. eventPackageInfo->mpEventSpecificSubscriptionMgr-> endSubscription(subscribeDialogHandle, SipSubscriptionMgr::subscriptionTerminated); // Do not send the NOTIFY. } } else { // Oops, the subscription was destroyed while we looked. OsSysLog::add(FAC_SIP, PRI_WARNING, "SipSubscribeServer::handleSubscribe " "subscription '%s' vanished while being processed", subscribeDialogHandle.data()); } // Send the response ASAP to minimize resending. setContact(&subscribeResponse); eventPackageInfo->mpEventSpecificUserAgent->send(subscribeResponse); } // Not authorized else { // Send the response that was prepared by ::isAuthorized(). setContact(&subscribeResponse); eventPackageInfo->mpEventSpecificUserAgent->send(subscribeResponse); } } // Not authenticated else { // Send the response that was prepared by ::isAuthenticated(). setContact(&subscribeResponse); eventPackageInfo->mpEventSpecificUserAgent->send(subscribeResponse); } } // We should not have received SUBSCRIBE requests for this event type. // This event type has not been enabled in this SubscribeServer. else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscribeServer::handleSubscribe event type: %s not enabled", eventName.data()); SipMessage eventTypeNotHandled; eventTypeNotHandled.setResponseData(&subscribeRequest, SIP_BAD_EVENT_CODE, SIP_BAD_EVENT_TEXT); setContact(&eventTypeNotHandled); mpDefaultUserAgent->send(eventTypeNotHandled); } unlockForRead(); return(handledSubscribe); }
/// Terminate all subscriptions and accept no new ones. void SipSubscribeServer::shutdown(const char* reason) { // If reason is NULL, use the default reason established by the constructor. if (!reason) { reason = mDefaultTermination; } OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::shutdown reason '%s'", reason ? reason : "[null]"); lockForRead(); // Select the subscriptionChange value to describe what we're doing // with the subscriptions. enum SipSubscriptionMgr::subscriptionChange change; // Select the correct format for generating the Subscription-State value. UtlString* formatp = NULL; // We may need a temp UtlString. const char* format; if (reason == NULL) { format = "active;expires=%ld"; change = SipSubscriptionMgr::subscriptionContinues; } else if (strcmp(reason, terminationReasonSilent) == 0) { // Do not admit that the subscription is ending. format = "active;expires=%ld"; change = SipSubscriptionMgr::subscriptionTerminatedSilently; } else if (strcmp(reason, terminationReasonNone) == 0) { format = "terminated"; change = SipSubscriptionMgr::subscriptionTerminated; } else { // Allocate a UtlString and assemble the Subscription-State format in it. formatp = new UtlString(); formatp->append("terminated;reason="); formatp->append(reason); format = formatp->data(); change = SipSubscriptionMgr::subscriptionTerminated; } // For each event type that is registered, delete all the subscriptions. UtlHashBagIterator event_itor(mEventDefinitions); SubscribeServerEventData* eventData; while ((eventData = dynamic_cast <SubscribeServerEventData*> (event_itor()))) { // Unregister interest in SUBSCRIBE requests and NOTIFY // responses for this event type, so we do not service new subscriptions. eventData->mpEventSpecificUserAgent->removeMessageObserver(*(getMessageQueue())); int numSubscriptions = 0; SipMessage** notifyArray = NULL; UtlString** acceptHeaderValuesArray = NULL; UtlString** resourceIdArray = NULL; UtlString** eventTypeKeyArray = NULL; // :TODO: The four situations where NOTIFYs are generated should // be factored into a series of methods in // mpEventSpecificSubscriptionMgr that generate NOTIFYs // sequentially, and for each NOTIFY, call a common service // method that does the remaining operations and sends the // NOTIFY. // Construct a NOTIFY (without body) for every subscription, containing // the dialog-related information about each subscription. eventData->mpEventSpecificSubscriptionMgr-> createNotifiesDialogInfoEvent(static_cast <const UtlString&> (*eventData), format, numSubscriptions, acceptHeaderValuesArray, notifyArray, resourceIdArray, eventTypeKeyArray); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::shutdown eventType = '%s', numSubscriptions = %d", eventData->data(), numSubscriptions); // For each NOTIFY, add the subscription-related information and then // send it. for (int notifyIndex = 0; notifyIndex < numSubscriptions; notifyIndex++) { SipMessage* notify = notifyArray[notifyIndex]; // Check to see if the dialog information could be added. // (The subscription might have been destroyed between when // it was decided to respond to it, and when the dialog information // was retrieved.) UtlString callId; notify->getCallIdField(&callId); if (!callId.isNull()) { if (change != SipSubscriptionMgr::subscriptionTerminatedSilently) { // Fill in the NOTIFY request body/content eventData->mpEventSpecificHandler-> getNotifyContent(*(resourceIdArray[notifyIndex]), *(eventTypeKeyArray[notifyIndex]), *eventData, *(eventData->mpEventSpecificContentMgr), *(acceptHeaderValuesArray[notifyIndex]), *notify, eventData->mEventSpecificFullState, NULL); // Call the application callback to edit the NOTIFY // content if that is required for this event type. // Also gets 'version' (if relevant) and 'savedEventTypeKey'. int version; UtlString savedEventTypeKey; eventData->mpEventSpecificSubscriptionMgr-> updateNotifyVersion(eventData->mpEventSpecificContentVersionCallback, *notify, version, savedEventTypeKey); // Set the Contact header. setContact(notify); // Send the NOTIFY request. eventData->mpEventSpecificUserAgent->send(*notify); } // Remove the record of the subscription. UtlString dialogHandle; notify->getDialogHandle(dialogHandle); eventData->mpEventSpecificSubscriptionMgr-> endSubscription(dialogHandle, change); } } // Free the NOTIFY requests and accept header field values. SipSubscriptionMgr::freeNotifies(numSubscriptions, acceptHeaderValuesArray, notifyArray); // Free the resource and event type arrays. for (int index = 0; index < numSubscriptions; index++) { delete resourceIdArray[index]; delete eventTypeKeyArray[index]; } delete[] resourceIdArray; delete[] eventTypeKeyArray; // Remove eventData from mEventDefinitions. mEventDefinitions.removeReference(eventData); delete eventData; } unlockForRead(); // Free the temporary UtlString, if necessary. if (formatp) { delete formatp; } lockForWrite(); mEventDefinitions.destroyAll(); unlockForWrite(); }
// Send a NOTIFY to all subscribers to the given resourceId and eventTypeKey. UtlBoolean SipSubscribeServer::notifySubscribers(const char* resourceId, const char* eventTypeKey, const char* eventType, const char* reason) { OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers resourceId '%s', eventTypeKey '%s', eventType '%s', reason '%s'", resourceId, eventTypeKey, eventType, reason ? reason : "[null]"); UtlBoolean notifiedSubscribers = FALSE; UtlString eventName(eventType); lockForRead(); SubscribeServerEventData* eventData = dynamic_cast <SubscribeServerEventData*> (mEventDefinitions.find(&eventName)); // Get the event-specific info to find subscriptions interested in // this content. if (eventData) { int numSubscriptions = 0; SipMessage** notifyArray = NULL; UtlString** acceptHeaderValuesArray = NULL; // Select the subscriptionChange value to describe what we're doing // with the subscriptions. enum SipSubscriptionMgr::subscriptionChange change; { // Select the correct format for generating the Subscription-State value. UtlString* formatp = NULL; // We may need a temp UtlString. const char* format; if (reason == NULL) { format = "active;expires=%ld"; change = SipSubscriptionMgr::subscriptionContinues; } else if (strcmp(reason, terminationReasonSilent) == 0) { // Do not admit that the subscription is ending. format = "active;expires=%ld"; change = SipSubscriptionMgr::subscriptionTerminatedSilently; } else if (strcmp(reason, terminationReasonNone) == 0) { format = "terminated"; change = SipSubscriptionMgr::subscriptionTerminated; } else { // Allocate a UtlString and assemble the Subscription-State format in it. formatp = new UtlString(); formatp->append("terminated;reason="); formatp->append(reason); format = formatp->data(); change = SipSubscriptionMgr::subscriptionTerminated; } // Construct a NOTIFY (without body) for each subscription, containing // the dialog-related information about each subscription. eventData->mpEventSpecificSubscriptionMgr-> createNotifiesDialogInfo(resourceId, eventTypeKey, format, numSubscriptions, acceptHeaderValuesArray, notifyArray); OsSysLog::add(FAC_SIP, PRI_DEBUG, "SipSubscribeServer::notifySubscribers numSubscriptions for '%s' = %d", resourceId, numSubscriptions); // Free the temporary UtlString, if necessary. if (formatp) { delete formatp; } } // For each NOTIFY, add the subscription-related information and then // send it. for (int notifyIndex = 0; notifyIndex < numSubscriptions; notifyIndex++) { SipMessage* notify = notifyArray[notifyIndex]; // Check to see if the dialog information could be added. // (The subscription might have been destroyed between when // it was decided to respond to it, and when the dialog information // was retrieved.) UtlString callId; notify->getCallIdField(&callId); if (!callId.isNull()) { if (change != SipSubscriptionMgr::subscriptionTerminatedSilently) { // Fill in the NOTIFY request body/content eventData->mpEventSpecificHandler-> getNotifyContent(resourceId, eventTypeKey, eventType, *(eventData->mpEventSpecificContentMgr), *(acceptHeaderValuesArray[notifyIndex]), *notify, eventData->mEventSpecificFullState, NULL); // Call the application callback to edit the NOTIFY // content if that is required for this event type. // Also gets 'version' (if relevant) and 'savedEventTypeKey'. int version; UtlString savedEventTypeKey; eventData->mpEventSpecificSubscriptionMgr-> updateNotifyVersion(eventData->mpEventSpecificContentVersionCallback, *notify, version, savedEventTypeKey); // Update the saved record of the NOTIFY CSeq and the // XML version number for the specified savedEventTypeKey, // as needed by the subscription manager. // In practice, this is only used by SipPersistentSubscriptionMgr // to write the NOTIFY Cseq and XML version into the IMDB. eventData->mpEventSpecificSubscriptionMgr-> updateVersion(*notify, version, savedEventTypeKey); // Set the Contact header. setContact(notify); // Send the NOTIFY request. eventData->mpEventSpecificUserAgent->send(*notify); } if (change != SipSubscriptionMgr::subscriptionContinues) { // Remove the record of the subscription. UtlString dialogHandle; notify->getDialogHandle(dialogHandle); eventData->mpEventSpecificSubscriptionMgr-> endSubscription(dialogHandle, change); } } } // Free the NOTIFY requests and accept header field values. eventData->mpEventSpecificSubscriptionMgr-> freeNotifies(numSubscriptions, acceptHeaderValuesArray, notifyArray); } // event type not enabled else { OsSysLog::add(FAC_SIP, PRI_ERR, "SipSubscribeServer::notifySubscribers " "event type: %s not enabled - " "Why are we seeing a callback for this?", eventName.data()); } unlockForRead(); return notifiedSubscribers; }
bool PHN_Sim::addContact(SimContact contact) { return setContact(-1, contact); }
// End a subscription because we got an error ersponse from a NOTIFY request. // This requires sending a terminating NOTIFY. void SipSubscribeServer::generateTerminatingNotify(const UtlString& dialogHandle) { // Sending a terminating NOTIFY presents the risk of an infinite // loop, as the terminating NOTIFY may get an error response. We // prevent this loop by removing record of the subscription as soon // as we send the terminating NOTIFY, and only initiating sending a // terminating NOTIFY if record of the subscription exists. // Not modifying the SubscribeServerEventData, just reading it. lockForRead(); // Get the event-specific handler and information. SubscribeServerEventData* eventPackageInfo; UtlHashBagIterator iterator(mEventDefinitions); // The terminating NOTIFY request that we will send. SipMessage notifyRequest; // We have to search for the right eventPackageInfo. while ((eventPackageInfo = dynamic_cast <SubscribeServerEventData*> (iterator()))) { UtlString resourceId; UtlString eventTypeKey; UtlString eventType; UtlString acceptHeaderValue; // Returns TRUE if eventPackageInfo->mpEventSpecificSubscriptionMgr // has this dialog. if (eventPackageInfo->mpEventSpecificSubscriptionMgr-> getNotifyDialogInfo(dialogHandle, notifyRequest, "terminated;reason=deactivated", &resourceId, &eventTypeKey, &eventType, &acceptHeaderValue)) { // There is still record of the subscription (hence a // terminating NOTIFY has not yet been sent), and this // eventPackageInfo has record of this subscription. // The NOTIFY headers were set by getNotifyDialogInfo. // Get the body for the NOTIFY. if (eventPackageInfo->mpEventSpecificHandler-> getNotifyContent(resourceId, eventTypeKey, eventType, *(eventPackageInfo->mpEventSpecificContentMgr), acceptHeaderValue, notifyRequest, eventPackageInfo->mEventSpecificFullState, NULL)) { // Update the NOTIFY content if required for this event type. // Sets 'version' and 'eventTypeKey'. int version; eventPackageInfo->mpEventSpecificSubscriptionMgr-> updateNotifyVersion(eventPackageInfo->mpEventSpecificContentVersionCallback, notifyRequest, version, eventTypeKey); // Update the saved record of the NOTIFY CSeq and the // XML version number for the specified eventTypeKey, // as needed by the subscription manager. // In practice, this is only used by SipPersistentSubscriptionMgr // to write the NOTIFY Cseq and XML version into the IMDB. eventPackageInfo->mpEventSpecificSubscriptionMgr-> updateVersion(notifyRequest, version, eventTypeKey); // Send the NOTIFY request setContact(¬ifyRequest); eventPackageInfo->mpEventSpecificUserAgent->send(notifyRequest); } // Destroy the subscription. // This prevents this method from sending a second terminating // NOTIFY for this subscription, even if it is called again. eventPackageInfo->mpEventSpecificSubscriptionMgr-> endSubscription(dialogHandle, SipSubscriptionMgr::subscriptionTerminated); } } unlockForRead(); }
BE::Contacts::Contacts(Gui::AbookAddressbook *abook): m_abook(abook), m_dirty(false) { m_currentContact = 0; QImage img(QDir::homePath() + "/.abook/incognito.png"); if (!img.isNull()) m_incognitoPic = QPixmap::fromImage(img.scaled(160,160,Qt::KeepAspectRatio,Qt::SmoothTransformation)); m_ui = new Ui::Contacts; m_ui->setupUi(this); #if QT_VERSION >= 0x040700 m_ui->filter->setPlaceholderText(tr("Filter")); #endif m_ui2 = new Ui::OneContact; m_ui2->setupUi(m_ui->oneContact); fields << Field(Gui::AbookAddressbook::Name, m_ui2->name, "name") << Field(Gui::AbookAddressbook::Mail, m_ui2->mail, "email") << Field(Gui::AbookAddressbook::Address, m_ui2->address, "address") << Field(Gui::AbookAddressbook::City, m_ui2->city, "city") << Field(Gui::AbookAddressbook::State, m_ui2->state, "state") << Field(Gui::AbookAddressbook::ZIP, m_ui2->zip, "zip") << Field(Gui::AbookAddressbook::Country, m_ui2->country, "country") << Field(Gui::AbookAddressbook::Phone, m_ui2->phone, "phone") << Field(Gui::AbookAddressbook::Workphone, m_ui2->workphone, "workphone") << Field(Gui::AbookAddressbook::Fax, m_ui2->fax, "fax") << Field(Gui::AbookAddressbook::Mobile, m_ui2->mobile, "mobile") << Field(Gui::AbookAddressbook::Nick, m_ui2->nick, "nick") << Field(Gui::AbookAddressbook::URL, m_ui2->url, "url") << Field(Gui::AbookAddressbook::Notes, m_ui2->notes, "notes") << Field(Gui::AbookAddressbook::Anniversary, m_ui2->anniversary, "anniversary") << Field(Gui::AbookAddressbook::Photo, m_ui2->photo, "photo"); m_sortFilterProxy = new QSortFilterProxyModel(this); m_sortFilterProxy->setFilterCaseSensitivity(Qt::CaseInsensitive); m_sortFilterProxy->setFilterKeyColumn(-1); m_sortFilterProxy->setSourceModel(m_abook->model()); connect (m_ui->filter, SIGNAL(textChanged(QString)), m_sortFilterProxy, SLOT(setFilterWildcard(QString))); m_ui->filter->installEventFilter(this); QFont fnt = m_ui2->name->font(); fnt.setPointSize(fnt.pointSize()*2); m_ui2->name->setFont(fnt); for (QList<Field>::const_iterator it = fields.constBegin(), end = fields.constEnd(); it != end; ++it) { it->label->installEventFilter(this); } m_ui->contacts->setModel(m_sortFilterProxy); m_ui->contacts->setSelectionMode(QAbstractItemView::SingleSelection); connect (m_ui->contacts->selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex)), SLOT(setContact(QModelIndex))); QModelIndex idx = m_sortFilterProxy->index(0,0); if (idx.isValid()) m_ui->contacts->setCurrentIndex(idx); m_ui->contacts->installEventFilter(this); connect (m_ui->add, SIGNAL(clicked()), SLOT(addContact())); connect (m_ui->remove, SIGNAL(clicked()), SLOT(removeCurrentContact())); connect (qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(updateFocusPolicy(QWidget*, QWidget*))); // cheat to correct the focuspolicies ;-) updateFocusPolicy(m_ui2->name, m_ui->filter); }
/*! \class QDeclarativeContactMetaObject \internal \brief open contact meta object for accessing dynamic contact detail properties in qml */ QDeclarativeContactMetaObject::QDeclarativeContactMetaObject(QObject* obj, const QContact& contact) :QDeclarativeOpenMetaObject(obj), m_modified(false) { setContact(contact); }
void BE::Contacts::saveContacts() { setContact(QModelIndex()); // store current contact changes m_abook->saveContacts(); }
ContactView::ContactView(QWidget* parent) : QWidget(parent), ui(new Ui::ContactView() ) { _address_book = nullptr; ui->setupUi(this); _addingNewContact = false; _editing = false; _modyfied = false; message_tools = new QToolBar( ui->toolbar_container ); QGridLayout* grid_layout = new QGridLayout(ui->toolbar_container); grid_layout->setContentsMargins(0, 0, 0, 0); grid_layout->setSpacing(0); ui->toolbar_container->setLayout(grid_layout); grid_layout->addWidget(message_tools, 0, 0); ui->email->setVisible (false); //unsupported ui->phone->setVisible (false); ui->phone_label->setVisible (false); ui->email_label->setVisible (false); ui->privacy_comboBox->setVisible (false); ui->privacy_level_label->setVisible (false);//unsupported //default contact view: info page ui->contact_pages->setCurrentIndex(info); send_mail = new QAction( QIcon( ":/images/128x128/contact_info_send_mail.png"), tr("Mail"), this); chat_contact = new QAction( QIcon( ":/images/chat.png"), tr("Chat"), this); edit_contact = new QAction( QIcon(":/images/128x128/contact_info_edit.png"), tr("Edit"), this); share_contact = new QAction(QIcon(":/images/read-icon.png"), tr("Share (need new icon)"), this); request_contact = new QAction( QIcon(":/images/128x128/contact_info_request_authorisation.png"), tr("Request authorisation"), this); save_contact = new QAction( QIcon(":/images/128x128/contact_info_save.png"), tr( "Save"), this ); cancel_edit_contact = new QAction( QIcon(":/images/128x128/contact_info_cancel_edit.png"), tr("Discard changes"), this); connect(ui->icon_view, &QToolButton::clicked, this, &ContactView::onIconSearch); message_tools->addAction(send_mail); message_tools->addAction(chat_contact); message_tools->addAction(share_contact); message_tools->addAction(request_contact); separatorToolBar = message_tools->addSeparator (); message_tools->addAction(edit_contact); message_tools->addAction(save_contact); message_tools->addAction(cancel_edit_contact); QLabel *label = new QLabel((tr(" Create new contact"))); label_createContact = message_tools->addWidget (label); QFont font; font.setBold(true); font.setPointSize (16); label->setFont (font); //ui->chat_conversation->setHtml( "<html><head></head><body>Hello World<br/></body></html>" ); connect(save_contact, &QAction::triggered, this, &ContactView::onSave); connect(cancel_edit_contact, &QAction::triggered, this, &ContactView::onCancel); connect(edit_contact, &QAction::triggered, this, &ContactView::onEdit); connect(send_mail, &QAction::triggered, this, &ContactView::onMail); connect(chat_contact, &QAction::triggered, this, &ContactView::onChat); connect(share_contact, &QAction::triggered, this, &ContactView::onShareContact); connect(request_contact, &QAction::triggered, this, &ContactView::onRequestContact); connect(ui->firstname, &QLineEdit::textChanged, this, &ContactView::firstNameChanged); connect(ui->lastname, &QLineEdit::textChanged, this, &ContactView::lastNameChanged); connect(ui->id_edit, &QLineEdit::textChanged, this, &ContactView::keyhoteeIdChanged); connect(ui->id_edit, &QLineEdit::textEdited, this, &ContactView::keyhoteeIdEdited); connect(ui->public_key, &QLineEdit::textEdited, this, &ContactView::publicKeyEdited); connect(ui->public_key, &QLineEdit::textChanged, this, &ContactView::publicKeyChanged); connect( ui->privacy_comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(privacyLevelChanged(int))); connect(ui->email, &QLineEdit::textChanged, this, &ContactView::emailChanged); connect(ui->phone, &QLineEdit::textChanged, this, &ContactView::phoneChanged); connect(ui->notes, &QPlainTextEdit::textChanged, this, &ContactView::notesChanged); connect(ui->public_key_to_clipboard, &QToolButton::clicked, this, &ContactView::onPublicKeyToClipboard); connect(ui->sendButton, &QPushButton::clicked, this, &ContactView::onSend); connect(ui->contact_pages, &QTabWidget::currentChanged, this, &ContactView::currentTabChanged); connect(ui->mining_effort_slider, &QSlider::valueChanged, this, &ContactView::onSliderChanged); keyEdit(false); ui->chat_input->installEventFilter(this); setContact(Contact() ); }
void qippda::loadMessages(const QString &path) { QDir dir = path; if(!dir.cd("History")) return; QHash<QString,QString> protocols; protocols[QLatin1String("icq")] = QLatin1String("ICQ"); protocols[QLatin1String("jabber")] = QLatin1String("Jabber"); protocols[QLatin1String("mra")] = QLatin1String("MRIM"); QStringList filters = QStringList() << QLatin1String("*.qhf") << QLatin1String("*.ahf"); QFileInfoList files = dir.entryInfoList(filters, QDir::Files); setMaxValue(files.size()); for(int i = 0; i < files.size(); i++) { setValue(i + 1); QString protocol = files[i].fileName().section("_",0,0); while(!protocol.isEmpty() && protocol.at(protocol.length() - 1).isDigit()) protocol.chop(1); // Old qip pda has only ICQ support and files are named like 1_myuin_hisuin if(protocol.isEmpty()) protocol = QLatin1String("ICQ"); else { protocol = protocols[protocol.toLower()]; if(protocol.isEmpty()) { qWarning("Unknown protocol: \"%s\"", qPrintable(files[i].fileName())); continue; } } setProtocol(protocol); QString account = files[i].fileName().section("_",1,1); setAccount(account); QFile file(files[i].absoluteFilePath()); if(file.open(QFile::ReadOnly)) { QByteArray bytearray = file.readAll(); const uchar *data = (const uchar *)bytearray.constData(); const uchar *end = data + bytearray.size(); if(memcmp(data, "QHF", 3)) continue; uchar version = data[3]; data += 44; QString uin = qipinfium::getString(data, qipinfium::getUInt16(data)); QString name = qipinfium::getString(data, qipinfium::getUInt16(data)); setContact(uin); // continue; while(data < end) { quint16 type = qipinfium::getUInt16(data); quint32 index = qipinfium::getUInt32(data); data += 2; const uchar *next = data + index; if(type == 1) { Message message; message.type = 1; data += 10; message.time = QDateTime::fromTime_t(qipinfium::getUInt32(data)); message.time.setTimeSpec(Qt::LocalTime); if(version == 1) message.time = message.time.toUTC().addDays(2); else message.time = message.time.toUTC(); data += 4; message.in = qipinfium::getUInt8(data) == 0; data += 4; int mes_len = version == 3 ? qipinfium::getUInt32(data) : qipinfium::getUInt16(data); QString text = qipinfium::getString(data, mes_len, version > 1); message.text = Qt::escape(text).replace("\n", "<br/>"); appendMessage(message); } else data = next; } } } }