本文整理汇总了C++中QMessage类的典型用法代码示例。如果您正苦于以下问题:C++ QMessage类的具体用法?C++ QMessage怎么用?C++ QMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QMessage类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contact
void SmsSender::started()
{
if(mMessage.size())
{
if(mContactNumber.isEmpty())
{
// Get number for contact id
QContactManager contactManager;
const QContact contact(contactManager.contact(mContactId));
const QList<QContactPhoneNumber> numbers(contact.details<QContactPhoneNumber>());
QStringList mobileNumbers;
foreach(const QContactPhoneNumber& number, numbers)
{
if(number.subTypes().contains(QContactPhoneNumber::SubTypeMobile)) mobileNumbers.append(number.number());
}
// Pick first mobile number
if(mobileNumbers.count()) mContactNumber = mobileNumbers.at(0);
}
// Create message
QMessage message;
message.setType(QMessage::Sms);
message.setTo(QMessageAddress(QMessageAddress::Phone, mContactNumber));
message.setBody(mMessage);
// Send it
mMessageService = new QMessageService(this);
connect(mMessageService, SIGNAL(stateChanged(QMessageService::State)), this, SLOT(stateChanged(QMessageService::State)));
mMessageService->send(message);
}
示例2: message
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);
}
}
示例3: foreach
void QFetionSMS::messageAdded ( const QMessageId & id, const QMessageManager::NotificationFilterIdSet & matchingFilterIds )
{
QMessage message = messageManager->message(id);
bool found = false;
if (!message.from().addressee().contains(cellphone))
{
foreach(const QMessageAddress &address,message.to())
{
if(address.addressee().contains(cellphone))
{
found = true;
break;
}
}
}else
示例4: qDebug
void EventLoggerEngine::addEvent(QMessage &message)
{
qDebug() << "EventLoggerEngine::addEvent()\n";
RTComElEvent *ev = rtcom_el_event_new();
if (message.type()==QMessage::Sms) {
RTCOM_EL_EVENT_SET_FIELD(ev,service,(gchar *)"RTCOM_EL_SERVICE_SMS");
}
else if (message.type()==QMessage::InstantMessage) {
RTCOM_EL_EVENT_SET_FIELD(ev,service,(gchar *)"RTCOM_EL_SERVICE_CHAT");
RTCOM_EL_EVENT_SET_FIELD(ev,remote_uid,(gchar *)message.from().addressee().toStdString().c_str());
RTCOM_EL_EVENT_SET_FIELD(ev,group_uid,(gchar *)message.from().addressee().toStdString().c_str());
}
else return; // Invalid messge type
RTCOM_EL_EVENT_SET_FIELD(ev,event_type,(gchar *)"RTCOM_EL_EVENTTYPE_SMS_INBOUND");
RTCOM_EL_EVENT_SET_FIELD(ev,local_uid,(gchar *)"ring/tel/ring");
RTCOM_EL_EVENT_SET_FIELD(ev,local_name,(gchar *)"<SelfHandle>");
RTCOM_EL_EVENT_SET_FIELD(ev,remote_uid,(gchar *)message.from().addressee().toStdString().c_str());
RTCOM_EL_EVENT_SET_FIELD(ev,group_uid,(gchar *)message.from().addressee().toStdString().c_str());
RTCOM_EL_EVENT_SET_FIELD(ev,start_time,time(NULL));
RTCOM_EL_EVENT_SET_FIELD(ev,remote_ebook_uid,(gchar *)"1");
RTCOM_EL_EVENT_SET_FIELD(ev,free_text,(gchar *)message.textContent().toStdString().c_str());
rtcom_el_add_event(el,ev,NULL);
rtcom_el_event_free(ev);
}
示例5: folderId
void QMessagePrivate::setStandardFolder(QMessage& message, QMessage::StandardFolder sf)
{
if (message.type() == QMessage::Email) {
QMessageFolderId folderId(standardFolderId(sf));
if (folderId.isValid()) {
message.d_ptr->_parentFolderId = folderId;
}
}
message.d_ptr->_standardFolder = sf;
message.d_ptr->_modified = true;
}
示例6: qDebug
void JBlockerMainWindow::slt_showInboxMessages()
{
qDebug() << "+ " << __PRETTY_FUNCTION__;
p_inboxW->clear();
/* Show messages classified based on sender's name */
p_nameToMessageHash = p_messageCore->getNameInfoHash();
/* Get name list */
QList<QString> nameList = p_nameToMessageHash.keys();
/* Get current account message type */
QMessage::TypeFlags accountType = p_messageCore->getCurrentAccountType();
/* Put classified infos into inbox tree widget */
for(int i=0; i<nameList.count(); i++)
{
QString name = nameList.at(i);
QStringList rootItemString;
/* Set the root element for each sender */
/* Check message type */
rootItemString << (accountType == QMessage::Sms ? p_messageCore->getContactName(name) : name) << QString("%1 message").arg(p_messageCore->messageCount(name));
QTreeWidgetItem* parentItem = new QTreeWidgetItem(rootItemString);
parentItem->setData(0, MessageIdRole, name);
p_inboxW->addTopLevelItem(parentItem);
/* Set children items for each sender */
QList<QMessage>* messageList = p_messageCore->getMessageList(name);
for(int j=0; j<messageList->count(); j++)
{
QMessage msg = messageList->at(j);
QStringList childItemString;
QString subject = QString::fromUtf8(msg.subject().toAscii());
childItemString << subject << msg.date().toLocalTime().toString(QString("hh:mm:ss dd.MM.yyyy"));
QTreeWidgetItem* childItem = new QTreeWidgetItem(childItemString);
/* Set messageID as the DATA of each children items */
childItem->setData(0, MessageIdRole, msg.id().toString());
/* Set the size hint of children */
childItem->setSizeHint(0, p_inboxW->headerItem()->sizeHint(0));
p_inboxW->topLevelItem(i)->addChild(childItem);
}
}
}
示例7: setError
bool QMFService::compose(const QMessage &message)
{
if (isBusy()) {
return false;
}
m_active = 0;
setError(QMessageManager::NoError);
QStringList arguments;
if (message.subject().size())
arguments << "--subject" << message.subject();
if (message.textContent().size())
arguments << "--body" << message.textContent();
if (message.cc().size())
arguments << "--cc" << MessagingHelper::addressListToString(message.cc());
if (message.bcc().size())
arguments << "--bcc" << MessagingHelper::addressListToString(message.bcc());
if (message.to().size())
arguments << MessagingHelper::addressListToString(message.to());
//qDebug() << __PRETTY_FUNCTION__ << " starting:" << XDG_PROG << arguments;
if (QProcess::execute(XDG_PROG, arguments) != 0) {
qWarning() << __PRETTY_FUNCTION__ << "Cannot start email composer: " << XDG_PROG << arguments;
setError(QMessageManager::FrameworkFault);
return false;
}
//qDebug() << __PRETTY_FUNCTION__ << "execution completed";
return true;
}
示例8: qDebug
void JBlockerMessageViewBox::slt_showMessage(QMessage msg, QMessage::TypeFlags msgType)
{
qDebug() << "+ " << __PRETTY_FUNCTION__;
/* Clear message box if needed */
this->slt_clear();
/* Template of the format to show message on message box */
static const QString htmlTemplate("\
<html>\
<head>\
</head>\
<body>\
<table border=\"0\" cellspacing=\"0\">\
<tr><td><b>From: </b></td><td>%1</td></tr>\
<tr><td><b>Subject: </b></td><td>%2</td></tr>\
<tr><td><b>Date: </b></td><td>%3</td></tr>\
</table>\
<hr>%4\
<\body>\
</html>\
");
/* BUG(Nokia Qt SDK): need to convert original text content into ascii and then convert back to utf-8 */
QString subject;
QString textContent;
/* Check message type */
switch(msgType)
{
case QMessage::Sms:
subject = QString::fromUtf8(msg.subject().toAscii());
textContent = QString::fromUtf8(msg.textContent().toAscii());
break;
case QMessage::Email:
subject = msg.subject();
textContent = msg.textContent();
break;
default:
qDebug() << "Not available message type";
return;
}
/* Show message in HTML format on message box */
p_textBrowser->setHtml(htmlTemplate\
.arg(msg.from().addressee())\
.arg(subject)\
.arg(msg.date().toLocalTime().toString(QString("hh:mm:ss dd.MM.yyyy")))\
.arg(textContent));
this->show();
}
示例9: switch
bool QMessageFilterPrivate::filter(const QMessage &message, const QMessageFilterPrivate &filter)
{
if ((filter._field == QMessageFilterPrivate::None) &&
(filter._filterList.count() == 0)) {
if (filter._notFilter) {
return false;
} else {
return true;
}
}
Qt::CaseSensitivity caseSensitivity = (filter._matchFlags & QMessageDataComparator::MatchCaseSensitive) ? Qt::CaseSensitive : Qt::CaseInsensitive;
switch (filter._field) {
case QMessageFilterPrivate::Id:
{
if (filter._comparatorType == QMessageFilterPrivate::Equality) {
QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(filter._comparatorValue));
if (cmp == QMessageDataComparator::Equal) {
if (message.id().toString() == filter._value.toString()) {
return true;
}
} else { // NotEqual
if (message.id().toString() != filter._value.toString()) {
return true;
}
}
} else if (filter._comparatorType == QMessageFilterPrivate::Inclusion) {
QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(filter._comparatorValue));
if (filter._ids.count() > 0) { // QMessageIdList
if (cmp == QMessageDataComparator::Includes) {
if (filter._ids.contains(message.id())) {
return true;
}
} else { // Excludes
if (!filter._ids.contains(message.id())) {
return true;
}
}
} else { // QMessageFilter
if (cmp == QMessageDataComparator::Includes) {
// TODO:
} else { // Excludes
// TODO:
}
}
}
break;
}
case QMessageFilterPrivate::Type:
{
QMessage::Type type = static_cast<QMessage::Type>(filter._value.toInt());
if (filter._comparatorType == QMessageFilterPrivate::Equality) {
QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(filter._comparatorValue));
if (cmp == QMessageDataComparator::Equal) {
if (message.type() == type) {
return true;
}
} else { // NotEqual
if (message.type() != type) {
return true;
}
}
} else if (filter._comparatorType == QMessageFilterPrivate::Inclusion) {
QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(filter._comparatorValue));
if (cmp == QMessageDataComparator::Includes) {
if ((message.type() & type) == message.type()) {
return true;
}
} else { // Excludes
if ((message.type() & type) == 0) {
return true;
}
}
}
break;
}
case QMessageFilterPrivate::Sender:
{
if (filter._comparatorType == QMessageFilterPrivate::Equality) {
QMessageDataComparator::EqualityComparator cmp(static_cast<QMessageDataComparator::EqualityComparator>(filter._comparatorValue));
if (cmp == QMessageDataComparator::Equal) {
if (filter._value.toString().length() > 0) {
if (message.from().addressee().compare(filter._value.toString(),caseSensitivity) == 0) {
return true;
}
}
} else { // NotEqual
if (filter._value.toString().length() > 0) {
if (message.from().addressee().compare(filter._value.toString(),caseSensitivity) != 0) {
return true;
}
} else {
return true;
}
}
} else if (filter._comparatorType == QMessageFilterPrivate::Inclusion) {
QMessageDataComparator::InclusionComparator cmp(static_cast<QMessageDataComparator::InclusionComparator>(filter._comparatorValue));
if (cmp == QMessageDataComparator::Includes) {
if (message.from().addressee().contains(filter._value.toString(),caseSensitivity)) {
//.........这里部分代码省略.........
示例10: accountName
void MessageSender::send()
{
//! [associate-account]
QString accountName(accountCombo->currentText());
if (accountName.isEmpty()) {
QMessageBox::warning(0, tr("Missing information"), tr("No account is selected for transmission"));
return;
}
QMessage message;
QPair<QMessage::Type, QMessageAccountId> details = accountDetails[accountName];
message.setType(details.first);
message.setParentAccountId(details.second);
//! [associate-account]
//! [set-recipients]
QString to(toEdit->text());
if (to.isEmpty()) {
QMessageBox::warning(0, tr("Missing information"), tr("Please enter a recipient address"));
return;
}
// Find the address type to use for this message
QMessageAddress::Type addrType(message.type() == QMessage::Email ? QMessageAddress::Email : QMessageAddress::Phone);
QMessageAddressList toList;
foreach (const QString &item, to.split(QRegExp("\\s"), QString::SkipEmptyParts)) {
toList.append(QMessageAddress(addrType, item));
}
message.setTo(toList);
//! [set-recipients]
//! [set-properties]
if (message.type() == QMessage::Email) {
QString subject(subjectEdit->text());
if (subject.isEmpty()) {
QMessageBox::warning(0, tr("Missing information"), tr("Please enter a subject"));
return;
}
message.setSubject(subject);
}
QString text(textEdit->toPlainText());
if (text.isEmpty()) {
QMessageBox::warning(0, tr("Missing information"), tr("Please enter a message"));
return;
}
message.setBody(text);
//! [set-properties]
//! [add-attachments]
if (message.type() != QMessage::Sms) {
if (attachmentsList->count()) {
QStringList paths;
for (int i = 0; i < attachmentsList->count(); ++i) {
paths.append(attachmentsList->item(i)->text());
}
message.appendAttachments(paths);
}
}
//! [add-attachments]
//! [send-message]
sendButton->setEnabled(false);
if (service.send(message)) {
sendId = message.id();
} else {
sendButton->setEnabled(true);
QMessageBox::warning(0, tr("Failed"), tr("Unable to send message"));
}
//! [send-message]
}
示例11: bzero
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();
};
};
示例12: if
QMessage EventLoggerEngine::eventToMessage(RTComElEvent & ev)
{
QMessage message;
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
};
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);
// qDebug() << "event_type:" << ev.fld_event_type << ev.fld_event_type_id << "Outgoing:" << ev.fld_outgoing << " Folder:" << message.standardFolder();
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 = QMessageId(QString("el")+QString::number(ev.fld_id));
privateMessage->_modified = false;
// qDebug() << "id:" << message.id().toString() << "From:" << message.from().addressee() << "Text:" << message.textContent();
return message;
}
示例13: addMessage
QMessageId addMessage(const Parameters ¶ms)
{
QString parentAccountName(params["parentAccountName"]);
QString parentFolderPath(params["parentFolderPath"]);
QString to(params["to"]);
QString from(params["from"]);
QString cc(params["cc"]);
QString bcc(params["bcc"]);
QString date(params["date"]);
QString receivedDate(params["receivedDate"]);
QString subject(params["subject"]);
QString text(params["text"]);
QString mimeType(params["mimeType"]);
QString attachments(params["attachments"]);
QString priority(params["priority"]);
QString size(params["size"]);
QString type(params["type"]);
QString read(params["status-read"]);
QString hasAttachments(params["status-hasAttachments"]);
QMessageManager mgr;
if (!to.isEmpty() && !from.isEmpty() && !date.isEmpty() && !subject.isEmpty() &&
!parentAccountName.isEmpty() && !parentFolderPath.isEmpty()) {
// Find the named account
QMessageAccountIdList accountIds(mgr.queryAccounts(QMessageAccountFilter::byName(parentAccountName)));
if (accountIds.count() == 1) {
// Find the specified folder
QMessageFolderFilter filter(QMessageFolderFilter::byPath(parentFolderPath, QMessageDataComparator::Equal) & QMessageFolderFilter::byParentAccountId(accountIds.first()));
QMessageFolderIdList folderIds(mgr.queryFolders(filter));
if (folderIds.count() == 1) {
QMessage message;
QMessagePrivate *p = MapiSession::privateMessage(message);
message.setParentAccountId(accountIds.first());
p->_parentFolderId = folderIds.first();
QMessage::StatusFlags flags(0);
if (read.toLower() == "true") {
flags |= QMessage::Read;
}
if (hasAttachments.toLower() == "true") {
flags |= QMessage::HasAttachments;
}
message.setStatus(flags);
QList<QMessageAddress> toList;
foreach (const QString &addr, to.split(",", QString::SkipEmptyParts)) {
toList.append(QMessageAddress(QMessageAddress::Email, addr.trimmed()));
}
message.setTo(toList);
QList<QMessageAddress> ccList;
foreach (const QString &addr, cc.split(",", QString::SkipEmptyParts)) {
ccList.append(QMessageAddress(QMessageAddress::Email, addr.trimmed()));
}
if (!ccList.isEmpty()) {
message.setCc(ccList);
}
QList<QMessageAddress> bccList;
foreach (const QString &addr, bcc.split(",")) {
if (!addr.isEmpty()) {
bccList.append(QMessageAddress(QMessageAddress::Email, addr.trimmed()));
}
}
message.setBcc(bccList);
message.setFrom(QMessageAddress(QMessageAddress::Email, from));
message.setSubject(subject);
QDateTime dt(QDateTime::fromString(date, Qt::ISODate));
dt.setTimeSpec(Qt::UTC);
message.setDate(dt);
if (type.isEmpty()) {
message.setType(QMessage::Email);
} else {
if (type.toLower() == "mms") {
message.setType(QMessage::Mms);
} else if (type.toLower() == "sms") {
message.setType(QMessage::Sms);
} else if (type.toLower() == "instantmessage") {
message.setType(QMessage::InstantMessage);
} else {
message.setType(QMessage::Email);
}
}
if (!receivedDate.isEmpty()) {
QDateTime dt(QDateTime::fromString(receivedDate, Qt::ISODate));
dt.setTimeSpec(Qt::UTC);
message.setReceivedDate(dt);
}
if (!priority.isEmpty()) {
if (priority.toLower() == "high") {
message.setPriority(QMessage::HighPriority);
} else if (priority.toLower() == "low") {
message.setPriority(QMessage::LowPriority);
//.........这里部分代码省略.........