EngineType idType(const QMessageId& id)
 {
     if (id.toString().startsWith(mtmPrefix)) {
         return EngineTypeMTM;
     } else if (id.toString().startsWith(freestylePrefix)) {
         return EngineTypeFreestyle;
     } else {
         return EngineTypeMTM;
     }
 }
示例#2
0
 QMessageId addIdPrefix(const QMessageId& id, const EngineType& type)
 {
     switch (type) {
     case EngineTypeFreestyle:
         Q_ASSERT(!id.toString().startsWith(freestylePrefix));
         return QMessageId(freestylePrefix + id.toString());
     case EngineTypeMTM:
         Q_ASSERT(!id.toString().startsWith(mtmPrefix));
         return QMessageId(mtmPrefix + id.toString());
     default:
         return QMessageId(id);
     }
 }
示例#3
0
bool QMessageStore::removeMessage(const QMessageId& id, QMessageManager::RemovalOption option)
{
    if (id.toString().startsWith("MO_")) {
        return ModestEngine::instance()->removeMessage(id, option);
    }
    return EventLoggerEngine::instance()->deleteMessage(id);
}
示例#4
0
QMessage QMessageStore::message(const QMessageId& id) const
{
    if (!id.isValid()) {
	d_ptr->error = QMessageManager::InvalidId;
	return QMessage();
    }

    d_ptr->error = QMessageManager::NoError;

    if (id.toString().startsWith("QMF_")) {
	return QMFStore::instance()->message(id, d_ptr->error); 
    } else if (id.toString().startsWith("SMS_")) {
	return StorageEngine::instance()->message(id);
    }

    d_ptr->error = QMessageManager::InvalidId;
    return QMessage();
}
QMessageFilter QMessageFilter::byId(const QMessageId &id, QMessageDataComparator::EqualityComparator cmp)
{
    QMessageFilter result;
    result.d_ptr->_field = QMessageFilterPrivate::Id;
    result.d_ptr->_value = id.toString();
    result.d_ptr->_comparatorType = QMessageFilterPrivate::Equality;
    result.d_ptr->_comparatorValue = static_cast<int>(cmp);
    result.d_ptr->_valid = true;
    return result;
}
示例#6
0
bool QMessageStore::removeMessage(const QMessageId& id, QMessageManager::RemovalOption option)
{
    bool ret = false;

    if (!id.isValid()) {
	d_ptr->error = QMessageManager::InvalidId;
	return false;
    }

    d_ptr->error = QMessageManager::NoError;

    if (id.toString().startsWith("QMF_")) {
	ret = QMFStore::instance()->removeMessage(id, option, d_ptr->error);
    } else if (id.toString().startsWith("SMS_")) {
	ret = StorageEngine::instance()->removeMessage(id);
    } else {
        d_ptr->error = QMessageManager::InvalidId;
    }

    return ret;
}
示例#7
0
QMessage QMessageStore::message(const QMessageId& id) const
{
    QMessage message = MessageCache::instance()->message(id);
    if (message.type() != QMessage::NoType) {
        return message;
    }

    if (id.toString().startsWith("MO_")) {
        return ModestEngine::instance()->message(id);
    } else {
        return d_ptr->p_ptr->el->message(id);
    }
}
 QMessageId stripIdPrefix(const QMessageId& id)
 {
     if (id.toString().startsWith(freestylePrefix))
         return QMessageId(id.toString().right(id.toString().length() - QString(freestylePrefix).length()));
     else if (id.toString().startsWith(mtmPrefix))
         return QMessageId(id.toString().right(id.toString().length() - QString(mtmPrefix).length()));
     else
         return QMessageId(id);
 }
bool QMFService::show(const QMessageId& id)
{
    if (isBusy()) {
        return false;
    }
    m_active = 0;
    setError(QMessageManager::NoError);

    if (!(id.toString().startsWith("QMF_") && id.isValid())) {
        setError(QMessageManager::InvalidId);
        return false;
    }

    //QMessage m(id);
    return compose(QMessage(id));
}
QMessage EventLoggerEngine::message(const QMessageId& id)
{

    QMessage message;

    // qDebug() << "EventLoggerEngine::getMessage id=" << id.toString();

    RTComElEvent ev;
    bzero(&ev,sizeof(ev));
    RTComElQuery *q=rtcom_el_query_new(el);
    rtcom_el_query_prepare(q,"id",id.toString().remove("el").toInt(),RTCOM_EL_OP_EQUAL,NULL);
    RTComElIter *iter=rtcom_el_get_events(el,q);
    g_object_unref(q);
    if(iter && rtcom_el_iter_first(iter))
    {
     gboolean res=rtcom_el_iter_get_full(iter,&ev);
     if(res) {
#if 0
         printf("got event id=%d service_id=%d event_typ_id=%d\n\
local_uid=%s local_name=%s\n\
remote_uid=%s remote_name=%s remote_ebook_uid=%s\n\
channel=%s free_text=%s group_uid=%s\n\
service=%s event_type=%s\n\
additional_text=%s icon_name=%s pango_markup=%s\n",
                    ev.fld_id,ev.fld_service_id,ev.fld_event_type_id,
                    ev.fld_local_uid,ev.fld_local_name,
                    ev.fld_remote_uid,ev.fld_remote_name,ev.fld_remote_ebook_uid,
                    ev.fld_channel,ev.fld_free_text,ev.fld_group_uid,
                    ev.fld_service,ev.fld_event_type,
                    ev.fld_additional_text,ev.fld_icon_name,ev.fld_pango_markup);
#endif
         if (!strcmp(ev.fld_service, "RTCOM_EL_SERVICE_SMS")) {
             message.setType(QMessage::Sms);
         } else if (!strcmp(ev.fld_service,"RTCOM_EL_SERVICE_CHAT")) {
             message.setType(QMessage::InstantMessage);
         } else {
             message.setType(QMessage::NoType);  // Other type, as exampele voice Call
         };
         //QMessageAccount account =  TelepathyEngine::instance()->account(QMessageAccountId(QString("/y/Account%1").arg(ev.fld_local_uid)));

         message.setParentAccountId(QMessageAccountId(QString("/y/Account/%1").arg(ev.fld_local_uid)));
         if (!ev.fld_is_read) {
             message.setStatus(QMessage::Read);
         };
         message.setPriority(QMessage::NormalPriority);
         message.setDate(QDateTime::fromTime_t(ev.fld_start_time));
         message.setReceivedDate(QDateTime::fromTime_t(ev.fld_start_time));
	 if (ev.fld_outgoing) QMessagePrivate::setStandardFolder(message,QMessage::SentFolder);
	 else
	   QMessagePrivate::setStandardFolder(message,QMessage::InboxFolder);

         if (ev.fld_outgoing) {
             // Outgoing message
             message.setFrom(QMessageAddress(QMessageAddress::Phone, QString(ev.fld_local_uid)));
             QMessagePrivate::setSenderName(message, QString(ev.fld_local_uid));
             message.setTo(QMessageAddress(QMessageAddress::Phone, QString(ev.fld_remote_uid)));
         } else {
             // Incoming message
             message.setFrom(QMessageAddress(QMessageAddress::Phone, QString(ev.fld_remote_uid)));
             QMessagePrivate::setSenderName(message, QString(ev.fld_remote_uid));
             QMessageAddressList messageAddresslist;
             messageAddresslist.append(QMessageAddress(QMessageAddress::Phone, QString(ev.fld_local_uid)));
             message.setTo(messageAddresslist);
         }

         message.setBody(QString::fromUtf8(ev.fld_free_text));
         QMessagePrivate* privateMessage = QMessagePrivate::implementation(message);
         privateMessage->_id = id;
         privateMessage->_modified = false;
	 //  qDebug() << "id:" << message.id().toString() << "From:" << message.from().addressee() << "Text:" << message.textContent();
     };
    };
bool EventLoggerEngine::deleteMessage(const QMessageId& id)
{
  int status=rtcom_el_delete_event(el,id.toString().remove("el").toInt(),NULL);
  return status==0;
}
示例#12
0
uint qHash(const QMessageId &id)
{
    return qHash(id.toString());
}
示例#13
0
QMailMessageId convert(const QMessageId &id)
{
    return QMailMessageId(stripIdentifierPrefix(id.toString()).toULongLong());
}