Exemple #1
0
xmlnode * _h_elim_image ( const char *name ,
                          const char *id   ,
                          SEXP_VALUE *args ,
                          gpointer data    )
{
    ASSERT_ALISTP( args, id, name );
    xmlnode *rval = xnode_new( "alist" );
    int image_id  = (int)ALIST_VAL_INT( args, "image-id" );

    if( image_id <= 0 )
    {
        sexp_val_free( args );
        return response_error( EINVAL, id, name, "bad image ID" );
    }

    fprintf( stderr, "searching for image id %d\n", image_id );
    PurpleStoredImage *image = purple_imgstore_find_by_id( image_id );
    
    if( !image )
    {
        sexp_val_free( args );
        return response_error( ENOENT, id, name, "image ID not found" );
    }

    size_t size = IGET( image , size );

    AL_INT ( rval, "image-id"  , image_id );
    AL_INT ( rval, "image-size", size     );
    AL_STR ( rval, "image-file", IGET( image, filename  ) );
    AL_STR ( rval, "image-type", IGET( image, extension ) );
    AL_DATA( rval, "image-data", IGET( image, data      ) , size );

    sexp_val_free( args );
    return response_value( 0, id, name, rval );
}
static void _elim_connect_progress        ( PurpleConnection *gc ,
                                            const char     *text ,
                                            size_t          step ,
                                            size_t    step_count )
{
    PurpleAccount *acct = purple_connection_get_account( gc );
    fprintf( stderr, "(_elim_connect_progress)\n" );

    if( acct )
    {
        char       *ID    = new_elim_id();
        xmlnode    *alist = xnode_new( "alist" );
        xmlnode    *mcall = func_call( "elim-connection-progress", ID, alist );
        const char *aname = purple_account_get_username   ( acct );
        const char *proto = purple_account_get_protocol_id( acct );
        int         state = purple_connection_get_state   ( gc   );
        g_free( ID );

        AL_PTR ( alist, "account-uid" , acct       );
        AL_STR ( alist, "account-name", aname      );
        AL_STR ( alist, "im-protocol" , proto      );
        AL_INT ( alist, "step"        , step       );
        AL_INT ( alist, "step-count"  , step_count );        
        AL_STR ( alist, "message"     , text       );
        AL_ENUM( alist, "state"       , state      , ":connection-state" );

        add_outbound_sexp( mcall );
    }

}
static void _elim_write_conv ( PurpleConversation *conv    ,
                               const char         *name    ,
                               const char         *alias   ,
                               const char         *message ,
                               PurpleMessageFlags  flags   ,
                               time_t mtime                )
{
    char    *msg   = NULL;
    char    *ID    = new_elim_id();
    xmlnode *args  = xnode_new( "alist" );
    xmlnode *mcall = func_call( "elim-conv-write-sys", ID, args );
    g_free( ID );
    fprintf( stderr, "(_elim_write_conv)\n" );

    if( _elim_strippable( conv, flags ) )
        msg = purple_markup_strip_html( message );

    _elim_conv_args( args, conv );
    AL_STR ( args, "who"  , (name  ? name  : (alias ? alias : "")) );
    AL_STR ( args, "alias", (alias ? alias : (name  ? name  : "")) );
    AL_STR ( args, "text" , msg ? msg : message );
    AL_ENUM( args, "flags", flags , ":message-flags" );
    AL_INT ( args, "time" , mtime );

    if( msg ) g_free( msg );
    fprintf( stderr, "(elim-debug _elim_write_conv:DONE)\n" );
    add_outbound_sexp( mcall );
}
Exemple #4
0
static void _elim_roomlist_add ( PurpleRoomlist     *list ,
                                 PurpleRoomlistRoom *room )
{
    g_return_if_fail( list && room );

    xmlnode *alist  = xnode_new( "alist" );
    char    *ID     = new_elim_id();

    __roomlist_insert_account( list->account, alist );
    AL_PTR ( alist , "roomlist-id" , list          );
    AL_STR ( alist , "room-name"   , room->name    );
    AL_ENUM( alist , "room-type"   , room->type    , ":roomlist-room-type" );
    AL_PTR ( alist , "room-parent" , room->parent  );
    AL_BOOL( alist , "room-expanded-once", room->expanded_once );

    xmlnode *fields = xnode_new_child( alist, "alist" );
    xnode_set_attrib( fields, "name", "fields" );

    GList *listf = g_list_first( list->fields );
    GList *roomf = g_list_first( room->fields );

#define NNEXTT( a, b ) a = g_list_next( a ), b = g_list_next( b )
#define PTR_TO_BOOL(_p) (_p != NULL)

    for( ; listf && roomf ; NNEXTT( listf, roomf ) )
    {
        PurpleRoomlistField *f = (PurpleRoomlistField*) listf->data;
        switch( f->type )
        {
          case PURPLE_ROOMLIST_FIELD_BOOL:
            AL_BOOL( fields, f->name, PTR_TO_BOOL( roomf->data ) );
            break;

          case PURPLE_ROOMLIST_FIELD_INT:
            AL_INT ( fields, f->name, roomf->data );
            break;

          case PURPLE_ROOMLIST_FIELD_STRING:
            AL_STR ( fields, f->name, roomf->data );
            break;

          default:
            fprintf( stderr, "unsupported room list field type.\n" );
            break;
        }
    }

    xmlnode *mcall = func_call( "elim-roomlist-add", ID, alist );
    g_free( ID );
    add_outbound_sexp( mcall );
}
static void
ujistoud (void)
{
  w_char *yomi;
  w_char dummy = 0;             /* 2 byte yomi */
  w_char *pyomi;                /* maeno tangono yomi */
  w_char *wcp;
  int serial_count;
  w_char *kosuup = NULL;

  *(int *) hostart = 0;
  uhopter = (struct uind2 *) ((int *) hostart + 1);

  yomi = &dummy;

  for (serial_count = 0; serial_count < jt.maxserial; serial_count++)
    {
      pyomi = yomi;
      yomi = jeary[serial_count]->yomi;

      if (wnn_Strcmp (yomi, pyomi))
        {
          tary[tnum++].pter = (char *) uhopter - (char *) hostart;
          uhopter->next = 0;
          uhopter->serial = serial_count;
          uhopter->kanjipter = kanjicount;
          uhopter->kosuu = 1;
          kosuup = &uhopter->kosuu;
          wcp = addyomient (tnum - 1, yomi);
          uhopter = (struct uind2 *) (AL_INT (wcp));
        }
      else
        {
          if (kosuup)
            *kosuup += 1;
        }
      upd_kanjicount (serial_count);
    }
}
static void
ujistosd (int start_je, int level)
{
  int state;
  int tsize;
  w_char *charst;
  w_char *sumst;
  int *ptrst;
  int mid_je, end_je;
  int je;
  int k;

  node_count++;

  tsize = analize_size (start_je, level, &state, &end_je, &mid_je);

  *(w_char *) hopter = state;
  hopter += 2;
  switch (state)
    {
    case ST_NORMAL:
      if (hopter + tsize * 8 + 12 + 16 >= hoend)
        not_enough_area ();
      *(w_char *) hopter = tsize;
      hopter += 2;
      *(int *) hopter = start_je;
      hopter += 4;
      *(int *) hopter = kanjicount;
      hopter += 4;
      charst = (w_char *) hopter;
      sumst = ((w_char *) hopter + tsize + 2);  /* + 2 keeps two zero words */
      charst[tsize] = charst[tsize + 1] = 0;
      ptrst = (int *) ((w_char *) sumst + tsize);
      hopter = (UCHAR *) (ptrst + tsize);
      for (k = 0; k < tsize; k++)
        {
          charst[k] = chartable[k];
          sumst[k] = numtable[k];
        }
      for (k = start_je; k < mid_je; k++)
        {
          upd_kanjicount (k);
        }
      for (je = mid_je, k = 0; je < end_je;)
        {
          for (; k < tsize && charst[k] < jeary[je]->yomi[level]; k++)
            ptrst[k] = ENDPTR;
          if (k == tsize)
            fprintf (stderr, "Error\n");
          ptrst[k] = (char *) hopter - (char *) hostart;
          ujistosd (je, level + 1);
          for (; je < end_je && jeary[je]->yomi[level] == charst[k]; je++);
          k++;
        }
      break;
    case ST_NOENT:
      if (hopter + tsize * 8 + 4 + 16 >= hoend)
        not_enough_area ();
      *(w_char *) hopter = tsize;
      hopter += 2;
      charst = (w_char *) hopter;
      ptrst = (int *) AL_INT ((w_char *) charst + tsize);
      hopter = (UCHAR *) (ptrst + tsize);
      for (k = 0; k < tsize; k++)
        {
          charst[k] = chartable[k];
        }
      for (je = mid_je, k = 0; je < end_je;)
        {
          for (; k < tsize && charst[k] < (jeary[je]->yomi)[level]; k++)
            ptrst[k] = ENDPTR;
          if (k == tsize)
            fprintf (stderr, "Error\n");
          ptrst[k] = (char *) hopter - (char *) hostart;
          ujistosd (je, level + 1);
          for (; je < end_je && (jeary[je]->yomi)[level] == charst[k]; je++);
          k++;
        }
      break;
    case ST_NOPTER:
      if (hopter + tsize * 4 + 12 + 16 >= hoend)
        not_enough_area ();
      *(w_char *) hopter = tsize;
      hopter += 2;
      *(int *) hopter = start_je;
      hopter += 4;
      *(int *) hopter = kanjicount;
      hopter += 4;
      charst = (w_char *) hopter;
      sumst = ((w_char *) hopter + tsize + 2);  /* + 2 keeps two zero words */
      charst[tsize] = charst[tsize + 1] = 0;
      hopter = (UCHAR *) ((w_char *) sumst + tsize);
      for (k = 0; k < tsize; k++)
        {
          charst[k] = chartable[k];
          sumst[k] = numtable[k];
        }
      for (k = start_je; k < mid_je; k++)
        {
          upd_kanjicount (k);
        }
      break;
    case ST_SMALL:
      if (hopter + 4 + 16 >= hoend)
        not_enough_area ();
      *(w_char *) hopter = chartable[0];
      hopter += 2;
      ujistosd (start_je, level + 1);
      break;
    }
}
Exemple #7
0
xmlnode * _h_elim_message ( const char *name ,
                            const char *id   ,
                            SEXP_VALUE *args ,
                            gpointer data    )
{
    fprintf(stderr, "(elim-debug entered _h_elim_message)");
    ASSERT_ALISTP( args, id, name );
    
    elim_ping();

    const char *aname = ALIST_VAL_STR( args, "account-name" );
    const char *proto = ALIST_VAL_STR( args, "im-protocol"  );
    gpointer    auid  = ALIST_VAL_PTR( args, "account-uid"  );

    PurpleAccount *acct = 
      auid ? find_acct_by_uid( auid ) : purple_accounts_find( aname, proto );

    if( !acct )
    {
        sexp_val_free( args );
        return response_error( ENXIO, id, name, "unknown account" );
    }

    PurpleConversationType pt = PURPLE_CONV_TYPE_UNKNOWN;
    gpointer             cuid = ALIST_VAL_PTR( args, "conv-uid"  );
    const char         *cname = ALIST_VAL_STR( args, "conv-name" );
    PurpleConversation    *pc = find_conv_by_acct_uid( acct, cuid );

    if  ( pc ) pt = purple_conversation_get_type( pc );
    else
    {
        pt = PURPLE_CONV_TYPE_ANY;
        pc = purple_find_conversation_with_account( pt, cname, acct );
        if( !pc )
        {
            pt = PURPLE_CONV_TYPE_IM;
            pc = purple_conversation_new( pt, acct, cname );
        }
        else { pt = purple_conversation_get_type( pc ); }
    }

    if( !pc )
    {
        sexp_val_free( args );
        return response_error( ENXIO, id, name, "new conversation failed" );
    }

    PurpleConvIm   *pci = NULL;
    PurpleConvChat *pcc = NULL;
    const char     *msg = ALIST_VAL_STRING( args, "text" );
    char           *esc = g_markup_escape_text( msg, -1 );
    int             len = strlen( esc );

    switch( pt )
    {
      case PURPLE_CONV_TYPE_IM:
        pci = purple_conversation_get_im_data( pc );
        purple_conv_im_send( pci, esc );
        break;
      case PURPLE_CONV_TYPE_CHAT:
        pcc = purple_conversation_get_chat_data( pc );
        purple_conv_chat_send( pcc, esc );
        break;
      default:
        g_free       ( esc  );
        sexp_val_free( args );
        return response_error( EINVAL, id, name, "unknown conversation type" );
    }

    xmlnode *rval = xnode_new( "alist" );
    AL_INT( rval, "bytes"    , len     );
    AL_PTR( rval, "conv-uid" , pc      );
    AL_STR( rval, "conv-name", purple_conversation_get_name(pc) );

    g_free       ( esc  );
    sexp_val_free( args );
    fprintf(stderr, "(elim-debug leaving _h_elim_message)");
    return response_value( 0, id, name, rval );
}