Exemple #1
0
static int send_JOIN_PLACE(struct mwPlace *place) {
  struct mwOpaque o = {0, 0};
  struct mwPutBuffer *b;
  int ret;

  b = mwPutBuffer_new();
  gboolean_put(b, FALSE);
  guint16_put(b, 0x01);
  guint16_put(b, 0x02); /* 0x01 */
  guint16_put(b, 0x01); /* 0x00 */

  mwPutBuffer_finalize(&o, b);

  ret = mwChannel_send(place->channel, msg_out_JOIN_PLACE, &o);

  mwOpaque_clear(&o);

  if(ret) {
    place_state(place, mwPlace_ERROR);
  } else {
    place_state(place, mwPlace_JOINING);
  }

  return ret;
}
Exemple #2
0
static void enc_offer_put(struct mwPutBuffer *b, struct mwEncryptOffer *enc) {
  guint16_put(b, enc->mode);

  if(enc->items) {
    guint32 count;
    struct mwPutBuffer *p;
    struct mwOpaque o;
    GList *list;

    /* write the count, items, extra, and flag into a tmp buffer,
       render that buffer into an opaque, and write it into b */

    count = g_list_length(enc->items);
    p = mwPutBuffer_new();

    guint32_put(p, count);
    for(list = enc->items; list; list = list->next) {
      mwEncryptItem_put(p, list->data);
    }

    guint16_put(p, enc->extra);
    gboolean_put(p, enc->flag);

    mwPutBuffer_finalize(&o, p);
    mwOpaque_put(b, &o);
    mwOpaque_clear(&o);
  }
}
Exemple #3
0
static int dir_open(struct mwDirectory *dir) {
  struct mwServiceDirectory *srvc;
  struct mwChannel *chan;
  struct mwPutBuffer *b;
  struct mwOpaque o;
  int ret;

  g_return_val_if_fail(dir != NULL, -1);

  srvc = dir->service;
  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, map_request(dir));

  /* unsure about these three bytes */
  gboolean_put(b, FALSE);
  guint16_put(b, 0x0000);

  guint32_put(b, dir->book->id);
  mwString_put(b, dir->book->name);

  mwPutBuffer_finalize(&o, b);
  ret = mwChannel_send(chan, action_open, &o);
  mwOpaque_clear(&o);

  return ret;
}
Exemple #4
0
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;
}
Exemple #5
0
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;
}
Exemple #6
0
static void CHANNEL_CREATE_put(struct mwPutBuffer *b,
			       struct mwMsgChannelCreate *msg) {

  guint32_put(b, msg->reserved);
  guint32_put(b, msg->channel);
  mwIdBlock_put(b, &msg->target);
  guint32_put(b, msg->service);
  guint32_put(b, msg->proto_type);
  guint32_put(b, msg->proto_ver);
  guint32_put(b, msg->options);
  mwOpaque_put(b, &msg->addtl);
  gboolean_put(b, msg->creator_flag);

  if(msg->creator_flag)
    mwLoginInfo_put(b, &msg->creator);

  enc_offer_put(b, &msg->encrypt);

  guint32_put(b, 0x00);
  guint32_put(b, 0x00);
  guint16_put(b, 0x07);
}