void dump_item( IDispatchPtr dispatch, QXmlStreamWriter &stream ) { TRACE(OutlookSyncPlugin) << "OutlookTodoSync::dump_item"; Q_ASSERT( dispatch ); Outlook::_TaskItemPtr item( dispatch ); Outlook::UserPropertiesPtr props = item->GetUserProperties(); Q_ASSERT(props); PREPARE_MAPI(Task); stream.writeStartElement("Task"); DUMP_STRING(Identifier,EntryID); DUMP_STRING(Description,Subject); QString high = "High"; QString low = "Low"; { Outlook::UserPropertyPtr up = props->Find("Qtopia Priority"); if ( up ) { QString priority = variant_to_qstring(up->GetValue()); if ( priority == "VeryHigh" && item->GetImportance() == Outlook::olImportanceHigh ) high = "VeryHigh"; if ( priority == "VeryLow" && item->GetImportance() == Outlook::olImportanceLow ) low = "VeryLow"; } } stream.writeStartElement("Priority"); DUMP_ENUM_V(Priority,Importance,Outlook::olImportanceHigh,high); DUMP_ENUM(Priority,Importance,Outlook::olImportanceNormal,Normal); DUMP_ENUM_V(Priority,Importance,Outlook::olImportanceLow,low); stream.writeEndElement(); stream.writeStartElement("Status"); DUMP_ENUM(Status,Status,Outlook::olTaskNotStarted,NotStarted); DUMP_ENUM(Status,Status,Outlook::olTaskInProgress,InProgress); DUMP_ENUM(Status,Status,Outlook::olTaskComplete,Completed); DUMP_ENUM(Status,Status,Outlook::olTaskWaiting,Waiting); DUMP_ENUM(Status,Status,Outlook::olTaskDeferred,Deferred); stream.writeEndElement(); DUMP_DATE(DueDate,DueDate); DUMP_DATE(StartedDate,StartDate); DUMP_DATE(CompletedDate,DateCompleted); DUMP_INT(PercentCompleted,PercentComplete); DUMP_MAPI(Notes,Body); stream.writeStartElement("Categories"); foreach ( const QString &category, bstr_to_qstring(item->GetCategories()).split(", ") ) DUMP_EXPR(Category,category); stream.writeEndElement(); stream.writeEndElement(); }
void ChatMsgArrivedNotify::process(InstancePtr instance, ConnectionPtr connection, const Uri& from, RequestMsg& msg) { instant_messaging_server::methods::rpc::ChatMsgArrivedNotify notify; if (!notify.ParseFromString(msg.data())) { LOG(error, "parse error! " << DUMP_STRING(msg.data())); throw ParseException(); } data_.reset(new Data); data_->sender = UserPtID(notify.sender_ua_uri(), instance->getDomain()); data_->msg_id = notify.msg_id(); data_->msg_time = notify.msg_time(); data_->content = notify.content(); data_->content_type = notify.content_type(); onNotification(instance); }
static void _be_dump(be_node *node, ssize_t indent) { size_t i; _be_dump_indent(indent); indent = abs(indent); switch (node->type) { case BE_STR: { long long len = be_str_len(node); printf("str = "); DUMP_STRING(node->val.s, len); printf(" (len = %lli)\n", len); break; } case BE_INT: printf("int = %lli\n", node->val.i); break; case BE_LIST: puts("list ["); for (i = 0; node->val.l[i]; ++i) _be_dump(node->val.l[i], indent + 1); _be_dump_indent(indent); puts("]"); break; case BE_DICT: puts("dict {"); for (i = 0; node->val.d[i].val; ++i) { _be_dump_indent(indent + 1); printf("%s => ", node->val.d[i].key); _be_dump(node->val.d[i].val, -(indent + 1)); } _be_dump_indent(indent); puts("}"); break; } }
void AckChatMsg::Callback::process(InstancePtr instance, const Uri& from, ResponseMsg& resp_msg, bool* need_more) { if (!resp_msg.has_err_code()) { instant_messaging_server::methods::rpc::AckChatMsgResponse ack_chat_resp; if (!ack_chat_resp.ParseFromString(resp_msg.data())) { LOG(error, "parse error! " << DUMP_STRING(resp_msg.data())); setError(instance, rpc::EC_RPC_PARSE_ERROR, "parse error"); return; } setResult(instance); } else { setError(instance, resp_msg.err_code(), resp_msg.err_msg()); } }
void ReminderNotify::process(InstancePtr instance, ConnectionPtr connection, const Uri& from, RequestMsg& msg) { instant_messaging_server::methods::rpc::UserNoticeArrivedNotify notify; if (!notify.ParseFromString(msg.data())) { LOG(error, "parse error! " << DUMP_STRING(msg.data())); throw ParseException(); } data_.reset(new Data); data_->sender = UserPtID(notify.sender_ua_uri(), instance->getDomain()); data_->time = notify.user_notice_time(); if (notify.user_notice_type() == "shaking-window remind") data_->reminder_type = REMINDER_SHAKING_WINDOW; else if (notify.user_notice_type() == "typing remind") data_->reminder_type = REMINDER_TYPING; else return; onNotification(instance); }
void ConnectionHandler::onMessage(rpc::OP op, rpc::MsgList& msg_list, const SockAddr& clientaddr) { LOG(trace, "onMessage: from " << addr() << " op=" << op); switch (op) { case rpc::OP_REQUEST: { Body failed_resp_body; for (rpc::MsgList::iterator it = msg_list.begin(); it != msg_list.end(); ++it) { rpc::RequestMsg r; if (!r.ParseFromString(*it)) { LOG(error, "parse request error! " << DUMP_STRING(*it)); continue; } base::ErrorCode ec; LOGI("ConnectionHandler::onMessage1\n"); if (!sp_stub_dispatcher_ || (!sp_stub_dispatcher_->invokeMethod( boost::static_pointer_cast<ConnectionHandler>(this->shared_from_this()), clientaddr, r, &ec) && IS_ERROR_EQUAL(ec, rpc::EC_RPC_METHOD_NOT_FOUND))) { LOGI("ConnectionHandler::onMessage2\n"); ec.reset(); svcref_.getCommunicator().getDefStubs().dispatcher()->invokeMethod( boost::static_pointer_cast<ConnectionHandler>(this->shared_from_this()), clientaddr, r, &ec); } if (ec) { LOGI("ConnectionHandler::onMessage3\n"); LOG(error, "process request (" << r << ") failed! " << ec); if (r.has_seq()) failed_resp_body.addFailedResponse(r.seq(), ec, ""); } } if (failed_resp_body.hasMsgs()) { base::ErrorCode ec; sendMessageBody(rpc::OP_RESPONSE, failed_resp_body, &ec); } } break; case rpc::OP_RESPONSE: { for (rpc::MsgList::iterator it = msg_list.begin(); it != msg_list.end(); ++it) { rpc::ResponseMsg resp; if (!resp.ParseFromString(*it)) { LOG(error, "parse error! " << DUMP_STRING(*it)); continue; } boost::shared_ptr<Request> req = requests_queue_.find(resp.seq()); if (req) { if (req->onResponse(resp)) { requests_queue_.pop(resp.seq()); req->setSeq(0); } } else LOG(warning, "corresponding request not found! seq=" << resp.seq()); } } break; case rpc::OP_NOOP: case rpc::OP_HEARTBEAT_ACK: break; case rpc::OP_HEARTBEAT: write(base::packet::Header(rpc::OP_HEARTBEAT_ACK), NULL, 0); break; default: LOG(warning, "unrecognized op! op=" << op); break; } }
void dump_item( const Outlook::_AppointmentItemPtr &item, QXmlStreamWriter &stream, bool dump_exception ) { TRACE(OutlookSyncPlugin) << "OutlookDatebookSync::dump_item"; Outlook::OlRecurrenceState recstate = item->GetRecurrenceState(); if ( recstate == Outlook::olApptOccurrence ) { WARNING() << "Cannot sync occurrences!"; return; } if ( (dump_exception && recstate != Outlook::olApptException) || (!dump_exception && recstate == Outlook::olApptException) ) { WARNING() << "Found" << (recstate == Outlook::olApptException?"Exception":"non-Exception") << "when syncing" << (dump_exception?"Exceptions":"non-Exceptions"); return; } Outlook::UserPropertiesPtr props = item->GetUserProperties(); Q_ASSERT(props); PREPARE_MAPI_DATEBOOK(Appointment, dump_exception); stream.writeStartElement("Appointment"); DUMP_STRING(Identifier,EntryID); DUMP_STRING(Description,Subject); DUMP_STRING(Location,Location); QString timezone; { Outlook::UserPropertyPtr up = props->Find("Qtopia Timezone"); if ( up ) { timezone = variant_to_qstring(up->GetValue()); } } DUMP_EXPR(TimeZone,timezone); stream.writeStartElement("When"); if ( item->GetAllDayEvent() ) { DUMP_DATE(StartDate,Start); // We can't just dump the end date because Outlook does it differently to Qtopia. // Qtopia expects something like "starts 7/10/08, ends 7/10/08" but Outlook // has given us "starts 7/10/08 00:00:00, ends 8/10/08 00:00:00". // Simply remove one day from the end date to get something Qtopia won't barf over. QDate dt = date_to_qdatetime(item->GetEnd()).date(); dt = dt.addDays(-1); DUMP_EXPR(EndDate,escape(dateToString(dt))); } else { QDateTime dt = date_to_qdatetime(item->GetStart()); bool utc = !timezone.isEmpty(); if ( utc ) dt = dt.toUTC(); DUMP_EXPR(Start,escape(dateTimeToString(dt, utc))); dt = date_to_qdatetime(item->GetEnd()); if ( utc ) dt = dt.toUTC(); DUMP_EXPR(End,escape(dateTimeToString(dt, utc))); } stream.writeEndElement(); stream.writeStartElement("Alarm"); if ( item->GetReminderSet() ) { DUMP_EXPR(Type,item->GetReminderPlaySound()?"Audible":"Visible"); DUMP_INT(Delay,ReminderMinutesBeforeStart); } stream.writeEndElement(); if ( !dump_exception ) { stream.writeStartElement("Repeat"); if ( recstate != Outlook::olApptNotRecurring && item->GetIsRecurring() ) { Q_ASSERT(recstate == Outlook::olApptMaster); Outlook::RecurrencePatternPtr recpat = item->GetRecurrencePattern(); Q_ASSERT(recpat); Outlook::OlRecurrenceType rectype = recpat->GetRecurrenceType(); LOG() << "recpat->RecurrenceType" << rectype; QString type; if ( rectype == Outlook::olRecursDaily && !recpat->GetDayOfWeekMask() ) type = "Daily"; else if ( ( rectype == Outlook::olRecursDaily && recpat->GetDayOfWeekMask() ) || rectype == Outlook::olRecursWeekly ) type = "Weekly"; else if ( rectype == Outlook::olRecursMonthly ) type = "MonthlyDate"; else if ( ( rectype == Outlook::olRecursMonthNth || rectype == Outlook::olRecursYearNth ) && recpat->GetInstance() != 5 ) type = "MonthlyDay"; else if ( ( rectype == Outlook::olRecursMonthNth || rectype == Outlook::olRecursYearNth ) && recpat->GetInstance() == 5 ) type = "MonthlyEndDay"; else if ( rectype == Outlook::olRecursYearly ) type = "Yearly"; Q_ASSERT(!type.isEmpty()); LOG() << "Type" << type << "Instance" << recpat->GetInstance(); stream.writeStartElement("Type"); stream.writeCharacters(type); stream.writeEndElement(); int frequency = recpat->GetInterval(); LOG() << "recpat->GetInterval" << frequency; if ( rectype == Outlook::olRecursDaily && recpat->GetDayOfWeekMask() ) frequency = 1; stream.writeStartElement("Frequency"); stream.writeCharacters(QString::number(frequency)); stream.writeEndElement(); stream.writeStartElement("Until"); if ( !recpat->GetNoEndDate() ) { LOG() << "recpat->GetPatternEndDate" << date_to_qdatetime(recpat->GetPatternEndDate()).date(); stream.writeCharacters(dateToString(date_to_qdatetime(recpat->GetPatternEndDate()).date())); } stream.writeEndElement(); if ( type == "Weekly" || type == "MonthlyDay" || type == "MonthlyEndDay" ) { stream.writeStartElement("WeekMask"); if ( recpat->GetDayOfWeekMask() ) { int mask = recpat->GetDayOfWeekMask(); LOG() << "recpat->GetDayOfWeekMask" << mask; QStringList list; if ( mask & Outlook::olMonday ) list << "Monday"; if ( mask & Outlook::olTuesday ) list << "Tuesday"; if ( mask & Outlook::olWednesday ) list << "Wednesday"; if ( mask & Outlook::olThursday ) list << "Thursday"; if ( mask & Outlook::olFriday ) list << "Friday"; if ( mask & Outlook::olSaturday ) list << "Saturday"; if ( mask & Outlook::olSunday ) list << "Sunday"; stream.writeCharacters(list.join(" ")); } else { LOG() << "recpat->GetDayOfWeekMask" << 0; } stream.writeEndElement(); } Outlook::ExceptionsPtr exceptions = recpat->GetExceptions(); if ( exceptions ) { int expcount = exceptions->GetCount(); for ( int i = 0; i < expcount; i++ ) { stream.writeStartElement("Exception"); long item_to_get = i+1; Outlook::ExceptionPtr exception = exceptions->Item(item_to_get); Q_ASSERT(exception); DUMP_DATE_ITEM(OriginalDate,OriginalDate,exception); if ( !exception->GetDeleted() ) { Outlook::_AppointmentItemPtr exceptionItem = exception->GetAppointmentItem(); dump_item( exceptionItem, stream, true ); } stream.writeEndElement(); } } } stream.writeEndElement(); } DUMP_MAPI(Notes,Body); stream.writeStartElement("Categories"); foreach ( const QString &category, bstr_to_qstring(item->GetCategories()).split(", ", QString::SkipEmptyParts) ) DUMP_EXPR(Category,category); stream.writeEndElement(); stream.writeEndElement(); }