/* 'compose' produces the un-changed *original* message sexp (ie., the message * to reply to, forward or edit) for a new message to compose). It takes two * parameters: 'type' with the compose type (either reply, forward or * edit/resend), and 'docid' for the message to reply to. Note, type:new does * not have an original message, and therefore does not need a docid * * In returns a (:compose <type> [:original <original-msg>] [:include] ) * message (detals: see code below) * * Note ':include' t or nil determines whether to include attachments */ static MuError cmd_compose (ServerContext *ctx, GHashTable *args, GError **err) { const gchar *typestr; char *sexp, *atts; unsigned ctype; MuMsgOptions opts; opts = get_encrypted_msg_opts (args); GET_STRING_OR_ERROR_RETURN (args, "type", &typestr, err); ctype = compose_type (typestr); if (ctype == INVALID_TYPE) { print_error (MU_ERROR_IN_PARAMETERS, "invalid type to compose"); return MU_OK; } if (ctype == REPLY || ctype == FORWARD || ctype == EDIT || ctype == RESEND) { MuMsg *msg; const char *docidstr; GET_STRING_OR_ERROR_RETURN (args, "docid", &docidstr, err); msg = mu_store_get_msg (ctx->store, atoi(docidstr), err); if (!msg) { print_and_clear_g_error (err); return MU_OK; } sexp = mu_msg_to_sexp (msg, atoi(docidstr), NULL, opts); atts = (ctype == FORWARD) ? include_attachments (msg, opts) : NULL; mu_msg_unref (msg); } else atts = sexp = NULL; print_expr ("(:compose %s :original %s :include %s)", typestr, sexp ? sexp : "nil", atts ? atts : "nil"); g_free (sexp); g_free (atts); return MU_OK; }
/********************************** Compose the character select screen **********************************/ item_t * scr_play_compose(context_t * ctx) { int bg_red = 0; int bg_blue = 0; int bg_green = 0; char * map_filename; int layer_index = 0; char * old_sfx = NULL; option = option_get(); if(item_list) { item_list_free(item_list); item_list = NULL; } if(ctx->map == NULL ) { if(context_update_from_file(ctx) == RET_NOK) { return NULL; } } if(init) { /* Register this character to receive server notifications */ network_request_start(ctx,ctx->id); ui_play_init(); init = false; } sdl_free_keycb(); sdl_free_mousecb(); sdl_add_mousecb(MOUSE_WHEEL_UP,cb_zoom); sdl_add_mousecb(MOUSE_WHEEL_DOWN,cb_unzoom); change_map = ctx->change_map; if( change_map == true ) { map_filename = strconcat( MAP_TABLE,"/",ctx->map,NULL); network_send_req_file(ctx,map_filename); free(map_filename); if(default_layer) { map_layer_delete(default_layer); } default_layer = map_layer_new(ctx->map,DEFAULT_LAYER,NULL); } if( default_layer && default_layer->active ) { // Make sure map data are available for(layer_index = 0; layer_index < MAX_LAYER; layer_index++) { compose_map_set(ctx,layer_index); compose_map_scenery(ctx,layer_index); compose_item(ctx,layer_index); compose_sprite(ctx,layer_index); compose_type(ctx,layer_index); } compose_map_button(ctx); compose_select(ctx); ui_play_compose(ctx,item_list); // force virtual coordinate on map change if( change_map == true ) { sdl_force_virtual_x(map_t2p_x(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_width[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_width[ctx->pos_ty%default_layer->row_num]/2 ); sdl_force_virtual_y(map_t2p_y(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_height[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_height[ctx->pos_ty%default_layer->row_num]/2 ); } // set virtual coordinate on the same map else { sdl_set_virtual_x(map_t2p_x(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_width[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_width[ctx->pos_ty%default_layer->row_num]/2 ); sdl_set_virtual_y(map_t2p_y(ctx->pos_tx,ctx->pos_ty,default_layer) + default_layer->col_height[ctx->pos_tx%default_layer->col_num]/2 + default_layer->row_height[ctx->pos_ty%default_layer->row_num]/2 ); } } entry_read_int(MAP_TABLE,ctx->map,&bg_red,MAP_KEY_BG_RED,NULL); entry_read_int(MAP_TABLE,ctx->map,&bg_blue,MAP_KEY_BG_BLUE,NULL); entry_read_int(MAP_TABLE,ctx->map,&bg_green,MAP_KEY_BG_GREEN,NULL); SDL_SetRenderDrawColor(ctx->render, bg_red, bg_blue, bg_green, 255); old_sfx = sfx; sfx = NULL; entry_read_string(MAP_TABLE,ctx->map,&sfx,MAP_SFX,NULL); if(old_sfx) { if( sfx ) { if( strcmp(old_sfx,sfx) ) { sfx_stop(ctx,old_sfx); } } else { // sfx == NULL sfx_stop(ctx,old_sfx); } free(old_sfx); } if( sfx && sfx[0]!=0 ) { sfx_play(ctx,sfx,NO_RESTART); } return item_list; }