int mwConference_invite(struct mwConference *conf, struct mwIdBlock *who, const char *text) { struct mwPutBuffer *b; struct mwOpaque o; int ret; g_return_val_if_fail(conf != NULL, -1); g_return_val_if_fail(conf->channel != NULL, -1); g_return_val_if_fail(who != NULL, -1); b = mwPutBuffer_new(); mwIdBlock_put(b, who); guint16_put(b, 0x00); guint32_put(b, 0x00); mwString_put(b, text); mwString_put(b, who->user); mwPutBuffer_finalize(&o, b); ret = mwChannel_sendEncrypted(conf->channel, msg_INVITE, &o, FALSE); mwOpaque_clear(&o); return ret; }
int mwPlace_sendText(struct mwPlace *place, const char *msg) { struct mwOpaque o = {0,0}; struct mwPutBuffer *b; int ret; b = mwPutBuffer_new(); guint32_put(b, 0x01); /* probably a message type */ mwString_put(b, msg); mwPutBuffer_finalize(&o, b); b = mwPutBuffer_new(); guint32_put(b, place->section); mwOpaque_put(b, &o); mwOpaque_clear(&o); mwPutBuffer_finalize(&o, b); ret = mwChannel_send(place->channel, msg_out_MESSAGE, &o); mwOpaque_clear(&o); return ret; }
int mwPlace_unsetAttribute(struct mwPlace *place, guint32 attrib) { struct mwOpaque o = {0,0}; struct mwPutBuffer *b; int ret; b = mwPutBuffer_new(); guint32_put(b, place->our_id); guint32_put(b, attrib); ret = mwChannel_send(place->channel, msg_out_SET_ATTR, &o); mwOpaque_clear(&o); return ret; }
struct mwStorageUnit *mwStorageUnit_newString(guint32 key, const char *str) { struct mwStorageUnit *u; struct mwPutBuffer *b; u = g_new0(struct mwStorageUnit, 1); u->key = key; b = mwPutBuffer_new(); mwString_put(b, str); mwPutBuffer_finalize(&u->data, b); return u; }
struct mwStorageUnit *mwStorageUnit_newInteger(guint32 key, guint32 val) { struct mwStorageUnit *u; struct mwPutBuffer *b; u = g_new0(struct mwStorageUnit, 1); u->key = key; b = mwPutBuffer_new(); guint32_put(b, val); mwPutBuffer_finalize(&u->data, b); return u; }
static int send_rem(struct mwChannel *chan, GList *id_list) { struct mwPutBuffer *b = mwPutBuffer_new(); struct mwOpaque o; int ret; g_return_val_if_fail(chan != NULL, 0); compose_list(b, id_list); mwPutBuffer_finalize(&o, b); ret = mwChannel_send(chan, msg_AWARE_REMOVE, &o); mwOpaque_clear(&o); return ret; }
static int send_SECTION_LIST(struct mwPlace *place, guint32 section) { int ret = 0; struct mwOpaque o = {0, 0}; struct mwPutBuffer *b; b = mwPutBuffer_new(); guint16_put(b, msg_out_SECTION_LIST); guint32_put(b, section); gboolean_put(b, FALSE); guint32_put(b, ++place->requests); mwPutBuffer_finalize(&o, b); ret = mwChannel_send(place->channel, msg_out_SECTION, &o); mwOpaque_clear(&o); return ret; }
static void ft_create_chan(struct mwFileTransfer *ft) { struct mwSession *s; struct mwChannelSet *cs; struct mwChannel *chan; struct mwLoginInfo *login; struct mwPutBuffer *b; /* we only should be calling this if there isn't a channel already associated with the conversation */ g_return_if_fail(ft != NULL); g_return_if_fail(mwFileTransfer_isNew(ft)); g_return_if_fail(ft->channel == NULL); s = mwService_getSession(MW_SERVICE(ft->service)); cs = mwSession_getChannels(s); chan = mwChannel_newOutgoing(cs); mwChannel_setService(chan, MW_SERVICE(ft->service)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); /* offer all known ciphers */ mwChannel_populateSupportedCipherInstances(chan); /* set the target */ login = mwChannel_getUser(chan); login->user_id = g_strdup(ft->who.user); login->community = g_strdup(ft->who.community); /* compose the addtl create */ b = mwPutBuffer_new(); guint32_put(b, 0x00); mwString_put(b, ft->filename); mwString_put(b, ft->message); guint32_put(b, ft->size); guint32_put(b, 0x00); guint16_put(b, 0x00); mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b); ft->channel = mwChannel_create(chan)? NULL: chan; if(ft->channel) { mwChannel_setServiceData(ft->channel, ft, NULL); } }
int mwConference_open(struct mwConference *conf) { struct mwSession *session; struct mwChannel *chan; struct mwPutBuffer *b; int ret; g_return_val_if_fail(conf != NULL, -1); g_return_val_if_fail(conf->service != NULL, -1); g_return_val_if_fail(conf->state == mwConference_NEW, -1); g_return_val_if_fail(conf->channel == NULL, -1); session = mwService_getSession(MW_SERVICE(conf->service)); g_return_val_if_fail(session != NULL, -1); if(! conf->name) { char *user = mwSession_getProperty(session, mwSession_AUTH_USER_ID); conf->name = conf_generate_name(user? user: "******"); } chan = mwChannel_newOutgoing(mwSession_getChannels(session)); mwChannel_setService(chan, MW_SERVICE(conf->service)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); #if 0 /* offer all known ciphers */ mwChannel_populateSupportedCipherInstances(chan); #endif b = mwPutBuffer_new(); mwString_put(b, conf->name); mwString_put(b, conf->title); guint32_put(b, 0x00); mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b); ret = mwChannel_create(chan); if(ret) { conf_state(conf, mwConference_ERROR); } else { conf_state(conf, mwConference_PENDING); conf->channel = chan; } return ret; }
int mwConference_sendText(struct mwConference *conf, const char *text) { struct mwPutBuffer *b; struct mwOpaque o; int ret; g_return_val_if_fail(conf != NULL, -1); g_return_val_if_fail(conf->channel != NULL, -1); b = mwPutBuffer_new(); guint32_put(b, 0x01); mwString_put(b, text); mwPutBuffer_finalize(&o, b); ret = mwChannel_sendEncrypted(conf->channel, msg_MESSAGE, &o, FALSE); mwOpaque_clear(&o); return ret; }
int mwPlace_legacyInvite(struct mwPlace *place, struct mwIdBlock *idb, const char *message) { struct mwOpaque o = {0,0}; struct mwPutBuffer *b; int ret; b = mwPutBuffer_new(); mwIdBlock_put(b, idb); mwString_put(b, idb->user); mwString_put(b, idb->user); mwString_put(b, message); gboolean_put(b, FALSE); mwPutBuffer_finalize(&o, b); ret = mwChannel_send(place->channel, msg_out_OLD_INVITE, &o); mwOpaque_clear(&o); return ret; }
int mwServiceDirectory_refreshAddressBooks(struct mwServiceDirectory *srvc) { struct mwChannel *chan; struct mwPutBuffer *b; struct mwOpaque o; int ret; g_return_val_if_fail(srvc != NULL, -1); chan = srvc->channel; g_return_val_if_fail(chan != NULL, -1); b = mwPutBuffer_new(); guint32_put(b, next_request_id(srvc)); mwPutBuffer_finalize(&o, b); ret = mwChannel_send(chan, action_list, &o); mwOpaque_clear(&o); return ret; }
int mwPlace_open(struct mwPlace *p) { struct mwSession *session; struct mwChannelSet *cs; struct mwChannel *chan; struct mwPutBuffer *b; int ret; g_return_val_if_fail(p != NULL, -1); g_return_val_if_fail(p->service != NULL, -1); session = mwService_getSession(MW_SERVICE(p->service)); g_return_val_if_fail(session != NULL, -1); cs = mwSession_getChannels(session); g_return_val_if_fail(cs != NULL, -1); chan = mwChannel_newOutgoing(cs); mwChannel_setService(chan, MW_SERVICE(p->service)); mwChannel_setProtoType(chan, PROTOCOL_TYPE); mwChannel_setProtoVer(chan, PROTOCOL_VER); mwChannel_populateSupportedCipherInstances(chan); b = mwPutBuffer_new(); mwString_put(b, mwPlace_getName(p)); mwString_put(b, mwPlace_getTitle(p)); guint32_put(b, 0x00); /* ? */ mwPutBuffer_finalize(mwChannel_getAddtlCreate(chan), b); ret = mwChannel_create(chan); if(ret) { place_state(p, mwPlace_ERROR); } else { place_state(p, mwPlace_PENDING); p->channel = chan; mwChannel_setServiceData(chan, p, NULL); } return ret; }
int mwConference_sendTyping(struct mwConference *conf, gboolean typing) { struct mwPutBuffer *b; struct mwOpaque o; int ret; g_return_val_if_fail(conf != NULL, -1); g_return_val_if_fail(conf->channel != NULL, -1); g_return_val_if_fail(conf->state == mwConference_OPEN, -1); b = mwPutBuffer_new(); guint32_put(b, 0x02); guint32_put(b, 0x01); guint32_put(b, !typing); mwOpaque_put(b, NULL); mwPutBuffer_finalize(&o, b); ret = mwChannel_sendEncrypted(conf->channel, msg_MESSAGE, &o, FALSE); mwOpaque_clear(&o); return ret; }
static int request_send(struct mwChannel *chan, struct mwStorageReq *req) { struct mwPutBuffer *b; struct mwOpaque o = { 0, 0 }; int ret; b = mwPutBuffer_new(); request_put(b, req); mwPutBuffer_finalize(&o, b); ret = mwChannel_send(chan, req->action, &o); mwOpaque_clear(&o); if(! ret) { if(req->action == action_save) { req->action = action_saved; } else if(req->action == action_load) { req->action = action_loaded; } } return ret; }
void MeanwhileSession::syncContactsToServer() { HERE; struct mwSametimeList *list = mwSametimeList_new(); /* set up a fallback group for top-level contacts */ struct mwSametimeGroup *topstgroup = mwSametimeGroup_new(list, mwSametimeGroup_DYNAMIC, "People"); mwSametimeGroup_setOpen(topstgroup, true); const QHash<QString, Kopete::Contact *> contacts = account->contacts(); // Q3DictIterator<Kopete::Contact> it(account->contacts()); for(QHash<QString, Kopete::Contact *>::const_iterator it = contacts.constBegin(); it != contacts.constEnd(); ++it ) { MeanwhileContact *contact = static_cast<MeanwhileContact *>(it.value()); /* Find the group that the metacontact is in */ Kopete::MetaContact *mc = contact->metaContact(); if (!mc) continue; Kopete::Group *contactgroup = mc->groups().value(0); if (!contactgroup) continue; if (contactgroup->type() == Kopete::Group::Temporary) continue; struct mwSametimeGroup *stgroup; if (contactgroup->type() == Kopete::Group::TopLevel) { stgroup = topstgroup; } else { /* find (or create) a matching sametime list group */ stgroup = mwSametimeList_findGroup(list, contactgroup->displayName().toUtf8().constData()); if (!stgroup) { stgroup = mwSametimeGroup_new(list, mwSametimeGroup_DYNAMIC, contactgroup->displayName().toUtf8().constData()); } mwSametimeGroup_setOpen(stgroup, contactgroup->isExpanded()); mwSametimeGroup_setAlias(stgroup, contactgroup->pluginData(account->protocol(), "alias").toUtf8().constData()); } QByteArray tmpMeanwhileId = contact->meanwhileId().toUtf8(); /* now add the user (by IDBlock) */ struct mwIdBlock id = { (gchar*)tmpMeanwhileId.constData(), 0 }; struct mwSametimeUser *stuser = mwSametimeUser_new(stgroup, mwSametimeUser_NORMAL, &id); mwSametimeUser_setAlias(stuser, mc->displayName().toUtf8().constData()); } /* store! */ struct mwPutBuffer *buf = mwPutBuffer_new(); struct mwStorageUnit *unit = mwStorageUnit_new(mwStore_AWARE_LIST); struct mwOpaque *opaque = mwStorageUnit_asOpaque(unit); mwSametimeList_put(buf, list); mwPutBuffer_finalize(opaque, buf); mwServiceStorage_save(storageService, unit, NULL, NULL, NULL); mwSametimeList_free(list); }