Esempio n. 1
0
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);
  }
}
Esempio n. 2
0
static void recv(struct mwServiceDirectory *srvc,
		 struct mwChannel *chan,
		 guint16 msg_type, struct mwOpaque *data) {
  
  g_return_if_fail(srvc != NULL);
  g_return_if_fail(chan != NULL);
  g_return_if_fail(chan == srvc->channel);
  g_return_if_fail(data != NULL);

  switch(msg_type) {
  case action_list:
    recv_list(srvc, data);
    break;

  case action_open:
    recv_open(srvc, data);
    break;

  case action_close:
    ; /* I don't think we should receive these */
    break;

  case action_search:
    recv_search(srvc, data);
    break;

  default:
    mw_mailme_opaque(data, "msg type 0x%04x in directory service", msg_type);
  }
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
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);
}
Esempio n. 5
0
static void recv(struct mwService *srvc, struct mwChannel *chan,
		 guint16 type, struct mwOpaque *data) {

  struct mwFileTransfer *ft;
  
  ft = mwChannel_getServiceData(chan);
  g_return_if_fail(ft != NULL);

  switch(type) {
  case msg_TRANSFER:
    recv_TRANSFER(ft, data);
    break;

  case msg_RECEIVED:
    recv_RECEIVED(ft, data);
    break;

  default:
    mw_mailme_opaque(data, "unknown message in ft service: 0x%04x", type);
  }
}