コード例 #1
0
ファイル: message.c プロジェクト: 0xmono/miranda-ng
static void LOGIN_get(struct mwGetBuffer *b, struct mwMsgLogin *msg) {
  if(mwGetBuffer_error(b)) return;

  guint16_get(b, &msg->login_type);
  mwString_get(b, &msg->name);
  mwOpaque_get(b, &msg->auth_data);
  guint16_get(b, &msg->auth_type);
}
コード例 #2
0
ファイル: message.c プロジェクト: 0xmono/miranda-ng
static void mwMessageHead_get(struct mwGetBuffer *b, struct mwMessage *msg) {

  if(mwGetBuffer_error(b)) return;

  guint16_get(b, &msg->type);
  guint16_get(b, &msg->options);
  guint32_get(b, &msg->channel);

  if(msg->options & mwMessageOption_HAS_ATTRIBS)
    mwOpaque_get(b, &msg->attribs);
}
コード例 #3
0
ファイル: srvc_conf.c プロジェクト: skelliam/meanwhile
static void WELCOME_recv(struct mwServiceConference *srvc,
			 struct mwConference *conf,
			 struct mwGetBuffer *b) {

  struct mwConferenceHandler *h;
  guint16 tmp16;
  guint32 tmp32;
  guint32 count;
  GList *l = NULL;

  /* re-read name and title */
  g_free(conf->name);
  g_free(conf->title);
  conf->name = NULL;
  conf->title = NULL;
  mwString_get(b, &conf->name);
  mwString_get(b, &conf->title);

  /* some numbers we don't care about, then a count of members */
  guint16_get(b, &tmp16);
  guint32_get(b, &tmp32);
  guint32_get(b, &count);

  if(mwGetBuffer_error(b)) {
    g_warning("error parsing welcome message for conference");
    mwConference_destroy(conf, ERR_FAILURE, NULL);
    return;
  }
  
  while(count--) {
    guint16 member_id;
    struct mwLoginInfo *member = g_new0(struct mwLoginInfo, 1);

    guint16_get(b, &member_id);
    mwLoginInfo_get(b, member);

    if(mwGetBuffer_error(b)) {
      login_free(member);
      break;
    }

    MEMBER_ADD(conf, member_id, member);
    l = g_list_append(l, member);
  }

  conf_state(conf, mwConference_OPEN);

  h = srvc->handler;
  if(h->conf_opened)
    h->conf_opened(conf, l);

  /* get rid of the GList, but not its contents */
  g_list_free(l);
}
コード例 #4
0
ファイル: srvc_place.c プロジェクト: mrcsparker/meanwhile
static int recv_SECTION(struct mwPlace *place, struct mwGetBuffer *b) {
  guint16 subtype;
  int res;

  guint16_get(b, &subtype);

  g_return_val_if_fail(! mwGetBuffer_error(b), -1);

  switch(subtype) {
  case msg_in_SECTION_LIST:
    res = recv_SECTION_LIST(place, b);
    break;

  case msg_in_SECTION_PEER:
    res = recv_SECTION_PEER(place, b);
    break;

  case msg_in_SECTION_PART:
    res = recv_SECTION_PART(place, b);
    break;

  default:
    res = -1;
  }

  return res;
}
コード例 #5
0
ファイル: message.c プロジェクト: 0xmono/miranda-ng
static void HANDSHAKE_get(struct mwGetBuffer *b, struct mwMsgHandshake *msg) {
  if(mwGetBuffer_error(b)) return;

  guint16_get(b, &msg->major);
  guint16_get(b, &msg->minor);
  guint32_get(b, &msg->head.channel);
  guint32_get(b, &msg->srvrcalc_addr);
  guint16_get(b, &msg->login_type);
  guint32_get(b, &msg->loclcalc_addr);

  if(msg->major >= 0x001e && msg->minor >= 0x001d) {
    guint16_get(b, &msg->unknown_a);
    guint32_get(b, &msg->unknown_b);
    mwString_get(b, &msg->local_host);
  }
}
コード例 #6
0
ファイル: srvc_dir.c プロジェクト: Seldom/miranda-ng
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);
  }
}
コード例 #7
0
ファイル: srvc_conf.c プロジェクト: skelliam/meanwhile
static void PART_recv(struct mwServiceConference *srvc,
		      struct mwConference *conf,
		      struct mwGetBuffer *b) {

  /* - parse who left
     - look up their membership
     - remove them from the members list
     - trigger the event
  */

  struct mwConferenceHandler *h;
  guint16 id = 0;
  struct mwLoginInfo *m;

  guint16_get(b, &id);

  if(mwGetBuffer_error(b)) return;

  m = MEMBER_FIND(conf, id);
  if(! m) return;

  h = srvc->handler;
  if(h->on_peer_parted)
    h->on_peer_parted(conf, m);

  MEMBER_REM(conf, id);
}
コード例 #8
0
ファイル: srvc_conf.c プロジェクト: skelliam/meanwhile
static void JOIN_recv(struct mwServiceConference *srvc,
		      struct mwConference *conf,
		      struct mwGetBuffer *b) {

  struct mwConferenceHandler *h;
  guint16 m_id;
  struct mwLoginInfo *m;
  
  /* for some inane reason, conferences we create will send a join
     message for ourselves before the welcome message. Since the
     welcome message will list our ID among those in the channel,
     we're going to just pretend that these join messages don't
     exist */
  if(conf->state == mwConference_PENDING)
    return;

  m = g_new0(struct mwLoginInfo, 1);

  guint16_get(b, &m_id);
  mwLoginInfo_get(b, m);

  if(mwGetBuffer_error(b)) {
    g_warning("failed parsing JOIN message in conference");
    login_free(m);
    return;
  }

  MEMBER_ADD(conf, m_id, m);

  h = srvc->handler;
  if(h->on_peer_joined)
    h->on_peer_joined(conf, m);
}
コード例 #9
0
ファイル: message.c プロジェクト: 0xmono/miranda-ng
static void HANDSHAKE_ACK_get(struct mwGetBuffer *b,
			      struct mwMsgHandshakeAck *msg) {

  if(mwGetBuffer_error(b)) return;

  guint16_get(b, &msg->major);
  guint16_get(b, &msg->minor);
  guint32_get(b, &msg->srvrcalc_addr);

  /** @todo: get a better handle on what versions support what parts
      of this message. eg: minor version 0x0018 doesn't send the
      following */
  if(msg->major >= 0x1e && msg->minor > 0x18) {
    guint32_get(b, &msg->magic);
    mwOpaque_get(b, &msg->data);
  }
}
コード例 #10
0
ファイル: message.c プロジェクト: 0xmono/miranda-ng
static void LOGIN_ACK_get(struct mwGetBuffer *b, struct mwMsgLoginAck *msg) {
  guint16 junk;

  if(mwGetBuffer_error(b)) return;

  mwLoginInfo_get(b, &msg->login);
  guint16_get(b, &junk);
  mwPrivacyInfo_get(b, &msg->privacy);
  mwUserStatus_get(b, &msg->status);
}
コード例 #11
0
ファイル: message.c プロジェクト: 0xmono/miranda-ng
static void enc_offer_get(struct mwGetBuffer *b,
			  struct mwEncryptOffer *enc) {
  guint32 skip;

  if(mwGetBuffer_error(b)) return;

  guint16_get(b, &enc->mode);
  guint32_get(b, &skip);

  if(skip >= 7) {
    guint32 count;

    guint32_get(b, &count);

    while(count-- && (! mwGetBuffer_error(b))) {
      struct mwEncryptItem *ei = g_new0(struct mwEncryptItem, 1);
      mwEncryptItem_get(b, ei);
      enc->items = g_list_append(enc->items, ei);
    }

    guint16_get(b, &enc->extra);
    gboolean_get(b, &enc->flag);
  }
コード例 #12
0
ファイル: srvc_place.c プロジェクト: mrcsparker/meanwhile
static int recv_SECTION_LIST(struct mwPlace *place,
			     struct mwGetBuffer *b) {
  int ret = 0;
  guint32 sec, count;

  mwGetBuffer_advance(b, 4);
  guint32_get(b, &sec);

  g_return_val_if_fail(sec == place->section, -1);

  mwGetBuffer_advance(b, 8);
  guint32_get(b, &count);
  mwGetBuffer_advance(b, 8);

  while(count--) {
    struct place_member *m;

    m = g_new0(struct place_member, 1);
    mwGetBuffer_advance(b, 4);
    guint32_get(b, &m->place_id);
    guint16_get(b, &m->member_type);
    mwIdBlock_get(b, &m->idb);
    mwString_get(b, &m->login_id);
    mwString_get(b, &m->name);
    guint16_get(b, &m->login_type);
    guint32_get(b, &m->unknown_a);
    guint32_get(b, &m->unknown_b);

    PUT_MEMBER(place, m);
  }

  if(place->state != mwPlace_OPEN)
    place_opened(place);

  return ret;
}
コード例 #13
0
ファイル: srvc_place.c プロジェクト: mrcsparker/meanwhile
static int recv_SECTION_PEER_JOIN(struct mwPlace *place,
				  struct mwGetBuffer *b) {
  struct mwServicePlace *srvc;
  struct place_member *pm;
  guint32 section;
  int ret = 0;

  srvc = place->service;

  guint32_get(b, &section);
  if(! section) {
    g_info("SECTION_PEER_JOIN with section 0x00");
    return 0;
  }

  mwGetBuffer_advance(b, 4);

  pm = g_new0(struct place_member, 1);
  guint32_get(b, &pm->place_id);
  guint16_get(b, &pm->member_type);
  mwIdBlock_get(b, &pm->idb);
  mwString_get(b, &pm->login_id);
  mwString_get(b, &pm->name);
  guint16_get(b, &pm->login_type);
  guint32_get(b, &pm->unknown_a);
  guint32_get(b, &pm->unknown_b);

  PUT_MEMBER(place, pm);
  if(srvc->handler && srvc->handler->peerJoined)
    srvc->handler->peerJoined(place, &pm->idb);

  if(pm->place_id == place->our_id)
    place_opened(place);

  return ret;
}
コード例 #14
0
ファイル: srvc_conf.c プロジェクト: skelliam/meanwhile
static void MESSAGE_recv(struct mwServiceConference *srvc,
			 struct mwConference *conf,
			 struct mwGetBuffer *b) {

  /* - look up who send the message by their id
     - trigger the event
  */

  guint16 id;
  guint32 type;
  struct mwLoginInfo *m;

  /* an empty buffer isn't an error, just ignored */
  if(! mwGetBuffer_remaining(b)) return;

  guint16_get(b, &id);
  guint32_get(b, &type); /* reuse type variable */
  guint32_get(b, &type);

  if(mwGetBuffer_error(b)) return;

  m = MEMBER_FIND(conf, id);
  if(! m) {
    g_warning("received message type 0x%04x from"
	      " unknown conference member %u", type, id);
    return;
  }
  
  switch(type) {
  case 0x01:  /* type is text */
    text_recv(srvc, conf, m, b);
    break;

  case 0x02:  /* type is data */
    data_recv(srvc, conf, m, b);
    break;

  default:
    g_warning("unknown message type 0x%4x received in conference", type);
  }
}