static void recv_list(struct mwServiceDirectory *srvc, struct mwOpaque *data) { struct mwGetBuffer *b; guint32 request, code, count; gboolean foo_1; guint16 foo_2; b = mwGetBuffer_wrap(data); guint32_get(b, &request); guint32_get(b, &code); guint32_get(b, &count); gboolean_get(b, &foo_1); guint16_get(b, &foo_2); if(foo_1 || foo_2) { mw_mailme_opaque(data, "received strange address book list"); mwGetBuffer_free(b); return; } while(!mwGetBuffer_error(b) && count--) { guint32 id; char *name = NULL; guint32_get(b, &id); mwString_get(b, &name); book_new(srvc, name, id); g_free(name); } }
static void recv(struct mwService *srvc, struct mwChannel *chan, guint16 type, struct mwOpaque *data) { /* process into results, trigger callbacks */ struct mwGetBuffer *b; struct mwServiceStorage *srvc_stor; struct mwStorageReq *req; guint32 id; g_return_if_fail(srvc != NULL); srvc_stor = (struct mwServiceStorage *) srvc; g_return_if_fail(chan != NULL); g_return_if_fail(chan == srvc_stor->channel); g_return_if_fail(data != NULL); b = mwGetBuffer_wrap(data); id = guint32_peek(b); req = request_find(srvc_stor, id); if(! req) { g_warning("couldn't find request 0x%x in storage service", id); mwGetBuffer_free(b); return; } g_return_if_fail(req->action == type); request_get(b, req); if(mwGetBuffer_error(b)) { mw_mailme_opaque(data, "storage request 0x%x, type: 0x%x", id, type); } else { request_trigger(srvc_stor, req); } mwGetBuffer_free(b); request_remove(srvc_stor, req); }
static void recv_channelCreate(struct mwServiceFileTransfer *srvc, struct mwChannel *chan, struct mwMsgChannelCreate *msg) { struct mwFileTransferHandler *handler; struct mwGetBuffer *b; char *fnm, *txt; guint32 size, junk; gboolean b_err; g_return_if_fail(srvc->handler != NULL); handler = srvc->handler; b = mwGetBuffer_wrap(&msg->addtl); guint32_get(b, &junk); /* unknown */ mwString_get(b, &fnm); /* offered filename */ mwString_get(b, &txt); /* offering message */ guint32_get(b, &size); /* size of offered file */ /// Miranda NG adaptation - start - http://www.lilotux.net/~mikael/pub/meanwhile/ft_fix.diff /* guint32_get(b, &junk); */ /* unknown */ /// Miranda NG adaptation - end /* and we just skip an unknown guint16 at the end */ b_err = mwGetBuffer_error(b); mwGetBuffer_free(b); if(b_err) { g_warning("bad/malformed addtl in File Transfer service"); mwChannel_destroy(chan, ERR_FAILURE, NULL); } else { struct mwIdBlock idb; struct mwFileTransfer *ft; login_into_id(&idb, mwChannel_getUser(chan)); ft = mwFileTransfer_new(srvc, &idb, txt, fnm, size); ft->channel = chan; ft_state(ft, mwFileTransfer_PENDING); mwChannel_setServiceData(chan, ft, NULL); if(handler->ft_offered) handler->ft_offered(ft); } g_free(fnm); g_free(txt); }
guint32 mwStorageUnit_asInteger(struct mwStorageUnit *item, guint32 val) { struct mwGetBuffer *b; guint32 v; g_return_val_if_fail(item != NULL, val); b = mwGetBuffer_wrap(&item->data); guint32_get(b, &v); if(! mwGetBuffer_error(b)) val = v; mwGetBuffer_free(b); return val; }
static void recv(struct mwService *service, struct mwChannel *chan, guint16 type, struct mwOpaque *data) { // `service` unused (void)service; struct mwPlace *place; struct mwGetBuffer *b; int res = 0; place = mwChannel_getServiceData(chan); g_return_if_fail(place != NULL); b = mwGetBuffer_wrap(data); switch(type) { case msg_in_JOIN_RESPONSE: res = recv_JOIN_RESPONSE(place, b); break; case msg_in_INFO: res = recv_INFO(place, b); break; case msg_in_MESSAGE: res = recv_MESSAGE(place, b); break; case msg_in_SECTION: res = recv_SECTION(place, b); break; case msg_in_UNKNOWNa: res = recv_UNKNOWNa(place, b); break; default: mw_mailme_opaque(data, "Received unknown message type 0x%x on place %s", type, NSTR(place->name)); } if(res) { mw_mailme_opaque(data, "Troubling parsing message type 0x0%x on place %s", type, NSTR(place->name)); } mwGetBuffer_free(b); }
static void recv_channelCreate(struct mwService *srvc, struct mwChannel *chan, struct mwMsgChannelCreate *msg) { /* - this is how we really receive invitations - create a conference and associate it with the channel - obtain the invite data from the msg addtl info - mark the conference as INVITED - trigger the got_invite event */ struct mwServiceConference *srvc_conf = (struct mwServiceConference *) srvc; struct mwConference *conf; struct mwGetBuffer *b; char *invite = NULL; guint tmp; conf = conf_new(srvc_conf); conf->channel = chan; b = mwGetBuffer_wrap(&msg->addtl); guint32_get(b, &tmp); mwString_get(b, &conf->name); mwString_get(b, &conf->title); guint32_get(b, &tmp); mwLoginInfo_get(b, &conf->owner); guint32_get(b, &tmp); mwString_get(b, &invite); if(mwGetBuffer_error(b)) { g_warning("failure parsing addtl for conference invite"); mwConference_destroy(conf, ERR_FAILURE, NULL); } else { struct mwConferenceHandler *h = srvc_conf->handler; conf_state(conf, mwConference_INVITED); if(h->on_invited) h->on_invited(conf, &conf->owner, invite); } mwGetBuffer_free(b); g_free(invite); }
char *mwStorageUnit_asString(struct mwStorageUnit *item) { struct mwGetBuffer *b; char *c = NULL; g_return_val_if_fail(item != NULL, NULL); b = mwGetBuffer_wrap(&item->data); mwString_get(b, &c); if(mwGetBuffer_error(b)) g_debug("error obtaining string value from opaque"); mwGetBuffer_free(b); return c; }