void    QFetionSMS::initial()
{
    if (!isInitialed)
    {
        messageManager = new QMessageManager(this);
        connect(messageManager,SIGNAL(messageAdded(QMessageId,QMessageManager::NotificationFilterIdSet)),this,SLOT(messageAdded(QMessageId,QMessageManager::NotificationFilterIdSet)));
        connect(messageManager,SIGNAL(messageRemoved(QMessageId,QMessageManager::NotificationFilterIdSet)),this,SLOT(messageRemoved(QMessageId,QMessageManager::NotificationFilterIdSet)));
        connect(messageManager,SIGNAL(messageUpdated(QMessageId,QMessageManager::NotificationFilterIdSet)),this,SLOT(messageUpdated(QMessageId,QMessageManager::NotificationFilterIdSet)));
        connect(this,SIGNAL(cellphoneChanged()),this,SLOT(getNewMessageList()));

        QHash<int, QByteArray> roleNames;
        roleNames[SubjectRole] = "subject";
        roleNames[SenderRole] = "sender";
        roleNames[ToRole] = "to";
        roleNames[SizeRole] = "size";
        roleNames[TypeRole] = "type";
        roleNames[DateRole] = "date";
        roleNames[ReceivedDateRole] = "receivedDate";
        roleNames[BodyRole] = "body";
        roleNames[PriorityRole] = "priority";
        roleNames[InboxRole] = "isInbox";
        roleNames[ReadyRole] = "ready";
        setRoleNames(roleNames);
        filterid = messageManager->registerNotificationFilter(QMessageFilter());

        isInitialed = true;
    }
}
QMFStore::QMFStore(QObject *parent)
    : QObject(parent),
      d_ptr(new QMFStorePrivate)
{
    connect(d_ptr, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)), this, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)));
    connect(d_ptr, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)), this, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)));
    connect(d_ptr, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)), this, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)));
}
AnonymousWithoutMessagesBuddyFilter::AnonymousWithoutMessagesBuddyFilter(QObject *parent)
	: AbstractBuddyFilter(parent), Enabled(false)
{
	connect(PendingMessagesManager::instance(), SIGNAL(messageAdded(Message)),
			this, SIGNAL(filterChanged()));
	connect(PendingMessagesManager::instance(), SIGNAL(messageRemoved(Message)),
			this, SIGNAL(filterChanged()));
}
    void testQOfonoMessageManager()
    {
        QSignalSpy sendMessage(m, SIGNAL(sendMessageComplete(bool, QString)));
        QSignalSpy messageAdded(m, SIGNAL(messageAdded(QString)));
        QSignalSpy messageRemoved(m, SIGNAL(messageRemoved(QString)));
        QSignalSpy immediateMessage(m, SIGNAL(immediateMessage(QString, QVariantMap)));
        QSignalSpy incomingMessage(m, SIGNAL(incomingMessage(QString, QVariantMap)));


        QStringList messages = m->messages();
        QVERIFY(messages.count() == 0);

        m->sendMessage("99999", "success");

        QTest::qWait(1000);

        QCOMPARE(sendMessage.count(), 1);
        QVariantList params = sendMessage.takeFirst();
        QCOMPARE(params.at(0).toBool(), true);
        QString objectPath = params.at(1).value<QString>();
        QVERIFY(objectPath.length() > 0);
        qDebug() << objectPath;

        QCOMPARE(messageAdded.count(), 1);
        QCOMPARE(messageRemoved.count(), 1);

        QString messageId = messageAdded.takeFirst().at(0).toString();
        QOfonoMessage* message = new QOfonoMessage();
        message->setMessagePath(messageId);
        QSignalSpy state(message, SIGNAL(stateChanged(const QString)));
        qDebug() << message->state();

        m->sendMessage("abc", "fail");

        QTest::qWait(1000);

        QCOMPARE(sendMessage.count(), 1);
        params = sendMessage.takeFirst();
        QCOMPARE(params.at(0).toBool(), false);
        objectPath = params.at(1).value<QString>();
        QVERIFY(objectPath.length() == 0);
    }
Exemple #5
0
void MsgListModel::handleRowsAboutToBeRemoved(const QModelIndex &parent, int start, int end)
{
    if (! parent.isValid()) {
        // Top-level items are tricky :(. As a quick hack, let's just die.
        resetMe();
        return;
    }

    checkPersistentIndex();
    if (! msgListPtr)
        return;

    TreeItem *item = Model::realTreeItem(parent);
    TreeItemMailbox *mailbox = dynamic_cast<TreeItemMailbox *>(item);
    TreeItemMsgList *newList = dynamic_cast<TreeItemMsgList *>(item);

    if (parent.isValid()) {
        Q_ASSERT(parent.model() == sourceModel());
    } else {
        // a top-level mailbox might have been deleted, so we gotta setup proper pointer
        mailbox = static_cast<Model *>(sourceModel())->m_mailboxes;
        Q_ASSERT(mailbox);
    }

    if (newList) {
        if (newList == msgListPtr) {
            beginRemoveRows(mapFromSource(parent), start, end);
            for (int i = start; i <= end; ++i)
                emit messageRemoved(msgListPtr->m_children[i]);
        }
    } else if (mailbox) {
        Q_ASSERT(start > 0);
        // if we're below it, we're gonna die
        for (int i = start; i <= end; ++i) {
            const Model *model = 0;
            QModelIndex translatedParent;
            Model::realTreeItem(parent, &model, &translatedParent);
            // FIXME: this assumes that no rows were removed by the proxy model
            TreeItemMailbox *m = dynamic_cast<TreeItemMailbox *>(static_cast<TreeItem *>(model->index(i, 0, translatedParent).internalPointer()));
            Q_ASSERT(m);
            TreeItem *up = msgListPtr->parent();
            while (up) {
                if (m == up) {
                    resetMe();
                    return;
                }
                up = up->parent();
            }
        }
    }
}
QMessageStorePrivatePlatform::QMessageStorePrivatePlatform(QMessageStorePrivate *d, QMessageStore *q)
    :d_ptr(d),
     q_ptr(q),
     error(QMessageManager::NoError),
     session(MapiSession::createSession(&error)),
     mutex(QMutex::Recursive)
{
    connect(QCoreApplication::instance(), SIGNAL(destroyed()), this, SLOT(appDestroyed()));

    if (session && (error == QMessageManager::NoError)) {
        MapiSession *o(session.data());
        connect(o, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)), q, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)));
        connect(o, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)), q, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)));
        connect(o, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)), q, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)));
    }
}
Exemple #7
0
BuddiesListView::BuddiesListView(QWidget *parent) :
		QTreeView(parent), Delegate(0), Model(0),
		ProxyModel(new BuddiesModelProxy(this)), BackgroundTemporaryFile(0),
		ContextMenuEnabled(false)
{
	setAnimated(BackgroundImageMode == BackgroundNone);
#ifndef Q_WS_MAEMO_5
	/* Disable as we use kinetic scrolling by default */
	setDragEnabled(true);
#endif
	setExpandsOnDoubleClick(false);
	setHeaderHidden(true);
	setItemsExpandable(true);
	setMouseTracking(true);
	setRootIsDecorated(true);
	setSelectionMode(QAbstractItemView::ExtendedSelection);
#ifndef Q_WS_MAEMO_5
	setUniformRowHeights(false);
#endif
	setWordWrap(true);

	Delegate = new BuddiesListViewDelegate(this);
	setItemDelegate(Delegate);

	HideUnloadedFilter = new ContactNoUnloadedAccountFilter(this);

	ToolTipTimeoutTimer.setSingleShot(true);

	connect(MainConfiguration::instance(), SIGNAL(simpleModeChanged()), this, SLOT(simpleModeChanged()));
	connect(&ToolTipTimeoutTimer, SIGNAL(timeout()), this, SLOT(toolTipTimeout()));
	connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(doubleClickedSlot(const QModelIndex &)));
	connect(PendingMessagesManager::instance(), SIGNAL(messageAdded(Message)), this, SLOT(update()));
	connect(PendingMessagesManager::instance(), SIGNAL(messageRemoved(Message)), this, SLOT(update()));

	simpleModeChanged();
}
void PendingMessagesManager::itemRemoved(Message message)
{
//	BuddyPreferredManager::instance()->updatePreferred(message.messageSender().ownerBuddy());
	emit messageRemoved(message);
}
Exemple #9
0
QTM_BEGIN_NAMESPACE

/*!
    \class QMessageManager

    \brief The QMessageManager class represents the main interface for storage and retrieval
    of messages, folders and accounts in the system message store.


    \inmodule QtMessaging

    \ingroup messaging
    \since 1.0

    The system contains a single store for messages, which is accessed via the handle
    class QMessageManager.  QMessageManager provides the interface for adding, updating
    and deleting messages in the system's message store.

    QMessageManager provides the countFolders() and queryFolders() functions for
    counting and listing the folders contained by the messaging store, and the
    countAccounts() and queryAccounts() functions for counting and listing the
    accounts contained by the store.  These functions use the QMessageFolderFilter
    and QMessageFolderSortOrder classes, and the QMessageAccountFilter and
    QMessageAccountSortOrder classes to constrain their searches.

    QMessageManager also implements functionality allowing the messages contained by the
    store to be counted or listed, using various filtering and sortOrder constraints.
    Clients can access this functionality via the \l{QMessageService::countMessages()}{countMessages}
    and \l{QMessageService::queryMessages()}{queryMessages} functions of the
    QMessageService class.

    With the exception of Windows mobile and desktop platforms, QMessageManager functions
    should not initiate network activity. Instead functions are restricted to operating
    on data already on the device. See QMessageService for functions related to
    initiating network activity.

    If a QMessageManager operation fails, the error() function will return an error code
    value indicating the failure mode encountered.  A successful operation will set the
    error() result to QMessageManager::NoError.

    Messages in the messaging store are identified by QMessageId objects. The data associated
    with a message is retrieved in the form of a QMessage object using message(). Likewise
    a folder is retrieved in the form of a QMessageFolder object using folder(), and an
    account is retrieved in the form of a QMessageAccount object using account().

    Messages can be inserted into the store using the addMessage() function, messages in the
    store can be manipulated via the updateMessage() function, and removed by the
    removeMessage() functions.

    Messaging store manipulations involving messages are reported via the messagesAdded(),
    messagesUpdated() and messagesRemoved() signals.

    \sa QMessage, QMessageId, QMessageContentContainerId, QMessageService
*/

/*!
    \enum QMessageManager::RemovalOption

    Defines whether or not a message will be removed from the originating server.

    \value RemoveLocalCopyOnly        Do not remove the message from the originating server.
    \value RemoveOnOriginatingServer  Remove the message both from the local store and from the originating server if any.
*/

/*!
    \typedef QMessageManager::NotificationFilterId

    This type contains a value identifying a registered message filter.
*/

/*!
    \typedef QMessageManager::NotificationFilterIdSet

    This type contains a set of values identifying registered message filters.
*/

/*!
    \enum QMessageManager::Error

    Defines the result of attempting to perform a messaging store operation.

    \value NoError                The operation was successfully performed.
    \value InvalidId              The operation failed due to the specification of an invalid identifier.
    \value ConstraintFailure      The operation failed due to a constraint violation.
    \value ContentInaccessible    The operation failed because the content data cannot be accessed by the messaging store.
    \value NotYetImplemented      The operation failed because the messaging store does not yet implement the operation.
    \value FrameworkFault         The operation failed because the messaging store encountered an error in performing the operation.
    \value WorkingMemoryOverflow  The operation failed because the messaging store exhausted all memory available for evaluating queries.
    \value Busy                   The operation failed because the messaging store is being used by another thread.
    \value RequestIncomplete      The operation failed to report successful completion, although no specific error was reported.
*/

/*!
    \fn QMessageManager::QMessageManager(QObject *parent)

    Constructs a handle to the message store.

    If \a parent is not 0 then the handle will be deleted when \a parent is deleted.
*/
QMessageManager::QMessageManager(QObject *parent)
    : QObject(parent),
      store(QMessageStore::instance())
{
    connect(store, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)), this, SIGNAL(messageAdded(QMessageId, QMessageManager::NotificationFilterIdSet)));
    connect(store, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)), this, SIGNAL(messageRemoved(QMessageId, QMessageManager::NotificationFilterIdSet)));
    connect(store, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)), this, SIGNAL(messageUpdated(QMessageId, QMessageManager::NotificationFilterIdSet)));

    connect(store, SIGNAL(accountRemoved(QMessageAccountId)), this, SIGNAL(accountRemoved(QMessageAccountId)));
}
Exemple #10
0
BuddiesListView::~BuddiesListView()
{
	disconnect(PendingMessagesManager::instance(), SIGNAL(messageAdded(Message)), this, SLOT(update()));
	disconnect(PendingMessagesManager::instance(), SIGNAL(messageRemoved(Message)), this, SLOT(update()));
}