Esempio n. 1
1
File: chat.cpp Progetto: schuay/sepm
void Chat::runSend(const QString &msg)
{
    bool success = true;
    QString message;

    sdc::Security s;
    try {
        QByteArray unencMsg = msg.toUtf8();
        sdc::ByteSeq encMsg = s.encryptAES(key,
                                           sdc::ByteSeq(unencMsg.begin(), unencMsg.end()));

        sessionPrx->sendMessage(encMsg, chatID.toStdString());

    } catch (const sdc::SecurityException &e) {
        // thrown by encryptAES
        success = false;
        message = e.what();
    } catch (const sdc::MessageException &e) {
        // thrown by sendMessage
        success = false;
        message = e.what.c_str();
    } catch (const sdc::InterServerException &e) {
        // thrown by sendMessage
        success = false;
        message = e.what.c_str();
    } catch (...) {
        success = false;
        message = "Unexpected exception";
    }

    emit sendCompleted(success, message);
}
Esempio n. 2
0
MailMessageClient::MailMessageClient(QObject* parent)
    : QObject(parent),
      adaptor(new QtopiaIpcAdaptor("QPE/QMailMessageServer", this))
{
    QtopiaIpcAdaptor::connect(this, SIGNAL(statusChanged(QMailMessageServer::Operation,QString,QString)),
                              adaptor, MESSAGE(statusChanged(QMailMessageServer::Operation, QString, QString)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(retrievalTotal(uint)),
                              adaptor, MESSAGE(retrievalTotal(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(retrievalProgress(uint)),
                              adaptor, MESSAGE(retrievalProgress(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(sendTotal(uint)),
                              adaptor, MESSAGE(sendTotal(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(sendProgress(uint)),
                              adaptor, MESSAGE(sendProgress(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(sendCompleted()), 
                              adaptor, MESSAGE(sendCompleted()));
    QtopiaIpcAdaptor::connect(this, SIGNAL(messageSent(QMailMessageId)), 
                              adaptor, MESSAGE(messageSent(QMailMessageId)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(errorOccurred(QMailAccountId,QString,int)),
                              adaptor, MESSAGE(errorOccurred(QMailAccountId, QString, int)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(newCountChanged(QMailMessageCountMap)),
                              adaptor, MESSAGE(newCountChanged(QMailMessageCountMap)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(partialMessageRetrieved(QMailMessageMetaData)),
                              adaptor, MESSAGE(partialMessageRetrieved(QMailMessageMetaData)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(messageRetrieved(QMailMessageMetaData)),
                              adaptor, MESSAGE(messageRetrieved(QMailMessageMetaData)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(partialRetrievalCompleted()),
                              adaptor, MESSAGE(partialRetrievalCompleted()));
    QtopiaIpcAdaptor::connect(this, SIGNAL(retrievalCompleted()),
                              adaptor, MESSAGE(retrievalCompleted()));
    QtopiaIpcAdaptor::connect(this, SIGNAL(searchTotal(uint)),
                              adaptor, MESSAGE(searchTotal(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(searchProgress(uint)),
                              adaptor, MESSAGE(searchProgress(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(matchingMessageIds(QMailMessageIdList)), 
                              adaptor, MESSAGE(matchingMessageIds(QMailMessageIdList)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(searchCompleted()), 
                              adaptor, MESSAGE(searchCompleted()));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(cancelSearch()),
                              this, SIGNAL(cancelSearch()));

    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(send(QMailMessageIdList)),
                              this, SIGNAL(send(QMailMessageIdList)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(retrieve(QMailAccountId, bool)),
                              this, SIGNAL(retrieve(QMailAccountId, bool)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(completeRetrieval(QMailMessageIdList)),
                              this, SIGNAL(completeRetrieval(QMailMessageIdList)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(cancelTransfer()),
                              this, SIGNAL(cancelTransfer()));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(acknowledgeNewMessages(QMailMessageTypeList)),
                              this, SIGNAL(acknowledgeNewMessages(QMailMessageTypeList)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(searchMessages(QMailMessageKey, QString)),
                              this, SIGNAL(searchMessages(QMailMessageKey, QString)));
}
// ############# Invokable API ########################
void EmailMessage::send()
{
    buildMessage();

    bool stored = false;

    if (!m_msg.id().isValid()) {
        // Message present only on the local device until we externalise or send it
        m_msg.setStatus(QMailMessage::LocalOnly, true);
        stored = QMailStore::instance()->addMessage(&m_msg);
    }
    else {
        stored = QMailStore::instance()->updateMessage(&m_msg);
        m_newMessage = false;
    }

    EmailAgent *emailAgent = EmailAgent::instance();
    if (stored) {
        connect(emailAgent, SIGNAL(sendCompleted()), this, SLOT(onSendCompleted()));
        emailAgent->sendMessages(m_msg.parentAccountId());
        emitSignals();
    }
    else
       qWarning() << "Error: queuing message, stored: " << stored;
}
Esempio n. 4
0
int
ProcessCommunicator :: testCompletion()
{
    return ( sendCompleted() && receiveCompleted() );
}
// ############ Slots ###############
void EmailMessage::onSendCompleted()
{
    emit sendCompleted();
}