bool QMessageId::operator==(const QMessageId& other) const
{
    if (isValid()) {
        return (other.isValid() ? (d_ptr->_id == other.d_ptr->_id) : false);
    } else {
        return !other.isValid();
    }
}
 EngineType idType(const QMessageId& id)
 {
     if (id.toString().startsWith(mtmPrefix)) {
         return EngineTypeMTM;
     } else if (id.toString().startsWith(freestylePrefix)) {
         return EngineTypeFreestyle;
     } else {
         return EngineTypeMTM;
     }
 }
bool QMessageId::operator<(const QMessageId& other) const
{
    if (isValid() && other.isValid())
        return (d_ptr->_id < other.d_ptr->_id);

    if (isValid()) {
        return false; // other is invalid, valid > invalid
    } else if (other.isValid()) {
        return true; // invalid < valid
    }
    return false; // both invalid
}
 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);
     }
 }
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));
}
Exemple #6
0
bool QMessageService::retrieve(const QMessageId &messageId, const QMessageContentContainerId& id)
{
	if (d_ptr->_active) {
		return false;
	}
	
    if (!messageId.isValid() || !id.isValid()) {
        d_ptr->_error = QMessageManager::InvalidId;
        return false;
    }
    
	d_ptr->_active = true;
	d_ptr->_error = QMessageManager::NoError;

	bool retVal = true;
	d_ptr->_state = QMessageService::ActiveState;
	emit stateChanged(d_ptr->_state);

	retVal = d_ptr->retrieve(messageId, id);
    if (retVal == false) {
        d_ptr->setFinished(retVal);
    }
	
    return retVal;
}
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);
}
MapiEntryId QMessageIdPrivate::storeRecordKey(const QMessageId &id)
{
    if (id.isValid()) {
        return id.d_ptr->_storeRecordKey;
    }

    return MapiEntryId();
}
MapiEntryId QMessageIdPrivate::entryId(const QMessageId &id)
{
    if (id.isValid()) {
        return id.d_ptr->_entryId;
    }

    return MapiEntryId();
}
Exemple #10
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;
}
Exemple #12
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;
}
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);
    }
}
bool QMessageId::operator==(const QMessageId& other) const
{
    if (isValid()) {
        if (other.isValid()) {
            bool result(d_ptr->_storeRecordKey == other.d_ptr->_storeRecordKey);
                if (result) {
                    QMessageManager::Error ignoredError(QMessageManager::NoError);
                    MapiSessionPtr session(MapiSession::createSession(&ignoredError));
                    if (ignoredError == QMessageManager::NoError) {
                        result &= session->equal(d_ptr->_entryId, other.d_ptr->_entryId);
                    } else {
                        result = false;
                        qWarning() << "Unable to compare entry IDs.";
                    }
                }
            return result;
        }
        return false;
    } else {
        return !other.isValid();
    }
}
 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);
 }
MapiEntryId QMessageIdPrivate::folderRecordKey(const QMessageId &id)
{
    if (id.isValid()) {
        if (!id.d_ptr->_folderRecordKey.isEmpty()) {
            return id.d_ptr->_folderRecordKey;
        } else {
            // Look up the folder record key for this ID
            QMessageManager::Error ignoredError(QMessageManager::NoError);
            MapiSessionPtr session(MapiSession::createSession(&ignoredError));
            if (ignoredError == QMessageManager::NoError) {
                return session->folderEntryId(&ignoredError, id);
            }
        }
    }

    return MapiEntryId();
}
MapiRecordKey QMessageIdPrivate::messageRecordKey(const QMessageId &id)
{
    MapiRecordKey result;

    if (id.isValid()) {
        if (id.d_ptr->_messageRecordKey.isEmpty()) {
            // Look up the message record key for this ID
            QMessageManager::Error ignoredError(QMessageManager::NoError);
            MapiSessionPtr session(MapiSession::createSession(&ignoredError));
            if (ignoredError == QMessageManager::NoError) {
                id.d_ptr->_messageRecordKey = session->messageRecordKey(&ignoredError, id);
            }
        }

        result = id.d_ptr->_messageRecordKey;
    }

    return result;
}
Exemple #18
0
bool QMessageService::show(const QMessageId& id)
{
	if (d_ptr->_active) {
		return false;
	}
	
    if (!id.isValid()) {
        d_ptr->_error = QMessageManager::InvalidId;
        return false;
    }
    
	d_ptr->_active = true;
	d_ptr->_error = QMessageManager::NoError;
	
	bool retVal = true;
	d_ptr->_state = QMessageService::ActiveState;
	emit stateChanged(d_ptr->_state);

    retVal = d_ptr->show(id);
    
    d_ptr->setFinished(retVal);
    return retVal;
}
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;
}
Exemple #21
0
QMailMessageId convert(const QMessageId &id)
{
    return QMailMessageId(stripIdentifierPrefix(id.toString()).toULongLong());
}
Exemple #22
0
uint qHash(const QMessageId &id)
{
    return qHash(id.toString());
}