/** Allocator function for a rdp context. * The function will allocate a rdpRdp structure using rdp_new(), then copy * its contents to the appropriate fields in the rdp_freerdp structure given in parameters. * It will also initialize the 'context' field in the rdp_freerdp structure as needed. * If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function. * * @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context. */ void freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdp = rdp_new(instance); // FIXME - we're not checking where rdp_new returns NULL, and have no way to report an error to the caller instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; instance->context = (rdpContext*) malloc(instance->context_size); ZeroMemory(instance->context, instance->context_size); instance->context->graphics = graphics_new(instance->context); instance->context->instance = instance; instance->context->rdp = rdp; instance->context->input = instance->input; instance->context->update = instance->update; instance->context->settings = instance->settings; instance->update->context = instance->context; instance->update->pointer->context = instance->context; instance->update->primary->context = instance->context; instance->update->secondary->context = instance->context; instance->update->altsec->context = instance->context; instance->input->context = instance->context; update_register_client_callbacks(rdp->update); IFCALL(instance->ContextNew, instance, instance->context); }
struct navit * navit_new(const char *ui, const char *graphics, struct coord *center, enum projection pro, int zoom) { struct navit *this_=g_new0(struct navit, 1); FILE *f; main_add_navit(this_); this_->vehicle_cbl=callback_list_new(); f=popen("pidof /usr/bin/ipaq-sleep","r"); if (f) { fscanf(f,"%d",&this_->pid); dbg(1,"ipaq_sleep pid=%d\n", this_->pid); pclose(f); } this_->bookmarks_hash=g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); this_->cursor_flag=1; this_->tracking_flag=1; this_->trans=transform_new(); transform_set_projection(this_->trans, pro); transform_setup(this_->trans, center, zoom, 0); this_->displaylist=graphics_displaylist_new(); this_->gui=gui_new(this_, ui, 792, 547); if (! this_->gui) { g_warning("failed to create gui '%s'", ui); navit_destroy(this_); return NULL; } if (gui_has_main_loop(this_->gui)) { if (! main_loop_gui) { main_loop_gui=this_->gui; } else { g_warning("gui with main loop already active, ignoring this instance"); navit_destroy(this_); return NULL; } } this_->menubar=gui_menubar_new(this_->gui); this_->toolbar=gui_toolbar_new(this_->gui); this_->statusbar=gui_statusbar_new(this_->gui); this_->gra=graphics_new(graphics); if (! this_->gra) { g_warning("failed to create graphics '%s'", graphics); navit_destroy(this_); return NULL; } graphics_register_resize_callback(this_->gra, navit_resize, this_); graphics_register_button_callback(this_->gra, navit_button, this_); if (gui_set_graphics(this_->gui, this_->gra)) { g_warning("failed to connect graphics '%s' to gui '%s'\n", graphics, ui); navit_destroy(this_); return NULL; } graphics_init(this_->gra); return this_; }
struct navit * navit_new(const char *ui, const char *graphics, struct coord *center, enum projection pro, int zoom) { struct navit *this_=g_new0(struct navit, 1); this_->cursor_flag=1; this_->trans=transform_new(); transform_set_projection(this_->trans, pro); transform_setup(this_->trans, center, zoom, 0); /* this_->flags=g_new0(struct map_flags, 1); */ this_->displaylist=graphics_displaylist_new(); this_->gui=gui_new(this_, ui, 792, 547); if (! this_->gui) { g_warning("failed to create gui '%s'", ui); navit_destroy(this_); return NULL; } if (gui_has_main_loop(this_->gui)) { if (! main_loop_gui) { main_loop_gui=this_->gui; } else { g_warning("gui with main loop already active, ignoring this instance"); navit_destroy(this_); return NULL; } } this_->menubar=gui_menubar_new(this_->gui); this_->toolbar=gui_toolbar_new(this_->gui); this_->statusbar=gui_statusbar_new(this_->gui); this_->gra=graphics_new(graphics); if (! this_->gra) { g_warning("failed to create graphics '%s'", graphics); navit_destroy(this_); return NULL; } graphics_register_resize_callback(this_->gra, navit_resize, this_); graphics_register_button_callback(this_->gra, navit_button, this_); if (gui_set_graphics(this_->gui, this_->gra)) { g_warning("failed to connect graphics '%s' to gui '%s'\n", graphics, ui); navit_destroy(this_); return NULL; } graphics_init(this_->gra); return this_; }
/** Allocator function for a rdp context. * The function will allocate a rdpRdp structure using rdp_new(), then copy * its contents to the appropriate fields in the rdp_freerdp structure given in parameters. * It will also initialize the 'context' field in the rdp_freerdp structure as needed. * If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function. * * @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context. */ int freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdpContext* context; instance->context = (rdpContext*) malloc(instance->ContextSize); ZeroMemory(instance->context, instance->ContextSize); context = instance->context; context->instance = instance; context->ServerMode = FALSE; context->settings = instance->settings; context->pubSub = PubSub_New(TRUE); PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType)); context->metrics = metrics_new(context); rdp = rdp_new(context); instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; context->graphics = graphics_new(context); context->rdp = rdp; context->input = instance->input; context->update = instance->update; context->settings = instance->settings; instance->update->context = instance->context; instance->update->pointer->context = instance->context; instance->update->primary->context = instance->context; instance->update->secondary->context = instance->context; instance->update->altsec->context = instance->context; instance->input->context = context; update_register_client_callbacks(rdp->update); IFCALL(instance->ContextNew, instance, instance->context); return 0; }
void freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdp = rdp_new(instance); instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; instance->context = (rdpContext*) xzalloc(instance->context_size); instance->context->graphics = graphics_new(instance->context); instance->context->instance = instance; instance->context->rdp = rdp; instance->update->context = instance->context; instance->input->context = instance->context; input_register_client_callbacks(rdp->input); IFCALL(instance->ContextNew, instance, instance->context); }
void freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdp = rdp_new(instance); instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; instance->context = (rdpContext*) xzalloc(instance->context_size); instance->context->graphics = graphics_new(instance->context); instance->context->instance = instance; instance->context->rdp = rdp; instance->update->context = instance->context; instance->update->pointer->context = instance->context; instance->update->primary->context = instance->context; instance->update->secondary->context = instance->context; instance->update->altsec->context = instance->context; instance->input->context = instance->context; IFCALL(instance->ContextNew, instance, instance->context); }
/** Allocator function for a rdp context. * The function will allocate a rdpRdp structure using rdp_new(), then copy * its contents to the appropriate fields in the rdp_freerdp structure given in parameters. * It will also initialize the 'context' field in the rdp_freerdp structure as needed. * If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function. * * @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context. */ BOOL freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdpContext* context; BOOL ret = TRUE; instance->context = (rdpContext*) calloc(1, instance->ContextSize); if (!instance->context) return FALSE; context = instance->context; context->instance = instance; context->ServerMode = FALSE; context->settings = instance->settings; context->pubSub = PubSub_New(TRUE); if(!context->pubSub) goto out_error_pubsub; PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType)); context->metrics = metrics_new(context); if (!context->metrics) goto out_error_metrics_new; rdp = rdp_new(context); if (!rdp) goto out_error_rdp_new; instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; instance->autodetect = rdp->autodetect; context->graphics = graphics_new(context); if(!context->graphics) goto out_error_graphics_new; context->rdp = rdp; context->input = instance->input; context->update = instance->update; context->settings = instance->settings; context->autodetect = instance->autodetect; instance->update->context = instance->context; instance->update->pointer->context = instance->context; instance->update->primary->context = instance->context; instance->update->secondary->context = instance->context; instance->update->altsec->context = instance->context; instance->input->context = context; instance->autodetect->context = context; update_register_client_callbacks(rdp->update); IFCALLRET(instance->ContextNew, ret, instance, instance->context); if (ret) return TRUE; out_error_graphics_new: rdp_free(rdp); out_error_rdp_new: metrics_free(context->metrics); out_error_metrics_new: PubSub_Free(context->pubSub); out_error_pubsub: free(instance->context); return FALSE; }
/** Allocator function for a rdp context. * The function will allocate a rdpRdp structure using rdp_new(), then copy * its contents to the appropriate fields in the rdp_freerdp structure given in parameters. * It will also initialize the 'context' field in the rdp_freerdp structure as needed. * If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function. * * @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context. */ BOOL freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdpContext* context; BOOL ret = TRUE; DWORD flags = WINPR_SSL_INIT_DEFAULT; instance->context = (rdpContext*) calloc(1, instance->ContextSize); if (!instance->context) return FALSE; context = instance->context; context->instance = instance; context->ServerMode = FALSE; context->settings = instance->settings; context->pubSub = PubSub_New(TRUE); if (!context->pubSub) goto fail; PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType)); context->metrics = metrics_new(context); if (!context->metrics) goto fail; rdp = rdp_new(context); if (!rdp) goto fail; instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; instance->autodetect = rdp->autodetect; context->graphics = graphics_new(context); if (!context->graphics) goto fail; context->rdp = rdp; context->input = instance->input; context->update = instance->update; context->settings = instance->settings; context->autodetect = instance->autodetect; instance->update->context = instance->context; instance->update->pointer->context = instance->context; instance->update->primary->context = instance->context; instance->update->secondary->context = instance->context; instance->update->altsec->context = instance->context; instance->input->context = context; instance->autodetect->context = context; if (!(context->errorDescription = calloc(1, 500))) { WLog_ERR(TAG, "calloc failed!"); goto fail; } if (!(context->channelErrorEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) { WLog_ERR(TAG, "CreateEvent failed!"); goto fail; } update_register_client_callbacks(rdp->update); instance->context->abortEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!instance->context->abortEvent) goto fail; if (!(context->channels = freerdp_channels_new(instance))) goto fail; IFCALLRET(instance->ContextNew, ret, instance, instance->context); if (ret) return TRUE; fail: freerdp_context_free(instance); return FALSE; }
/** Allocator function for a rdp context. * The function will allocate a rdpRdp structure using rdp_new(), then copy * its contents to the appropriate fields in the rdp_freerdp structure given in parameters. * It will also initialize the 'context' field in the rdp_freerdp structure as needed. * If the caller has set the ContextNew callback in the 'instance' parameter, it will be called at the end of the function. * * @param instance - Pointer to the rdp_freerdp structure that will be initialized with the new context. */ BOOL freerdp_context_new(freerdp* instance) { rdpRdp* rdp; rdpContext* context; BOOL ret = TRUE; instance->context = (rdpContext*) calloc(1, instance->ContextSize); if (!instance->context) return FALSE; context = instance->context; context->instance = instance; context->ServerMode = FALSE; context->settings = instance->settings; context->pubSub = PubSub_New(TRUE); if(!context->pubSub) goto out_error_pubsub; PubSub_AddEventTypes(context->pubSub, FreeRDP_Events, sizeof(FreeRDP_Events) / sizeof(wEventType)); context->metrics = metrics_new(context); if (!context->metrics) goto out_error_metrics_new; rdp = rdp_new(context); if (!rdp) goto out_error_rdp_new; instance->input = rdp->input; instance->update = rdp->update; instance->settings = rdp->settings; instance->autodetect = rdp->autodetect; context->graphics = graphics_new(context); if(!context->graphics) goto out_error_graphics_new; context->rdp = rdp; context->input = instance->input; context->update = instance->update; context->settings = instance->settings; context->autodetect = instance->autodetect; instance->update->context = instance->context; instance->update->pointer->context = instance->context; instance->update->primary->context = instance->context; instance->update->secondary->context = instance->context; instance->update->altsec->context = instance->context; instance->input->context = context; instance->autodetect->context = context; if (!(context->errorDescription = calloc(1, 500))) { WLog_ERR(TAG, "calloc failed!"); goto out_error_description; } if (!(context->channelErrorEvent = CreateEvent(NULL, TRUE, FALSE, NULL))) { WLog_ERR(TAG, "CreateEvent failed!"); goto out_error_create_event; } update_register_client_callbacks(rdp->update); instance->context->abortEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (!instance->context->abortEvent) goto out_error_abort_event; IFCALLRET(instance->ContextNew, ret, instance, instance->context); if (ret) return TRUE; CloseHandle(context->abortEvent); out_error_abort_event: CloseHandle(context->channelErrorEvent); out_error_create_event: free(context->errorDescription); out_error_description: graphics_free(context->graphics); out_error_graphics_new: rdp_free(rdp); out_error_rdp_new: metrics_free(context->metrics); out_error_metrics_new: PubSub_Free(context->pubSub); out_error_pubsub: free(instance->context); return FALSE; }