Hi,

Better try the opposite approach.

If you check the sample client, there already is a settings struct
allocated with default values when
freerdp_client_settings_parse_command_line is called.

Populate this struct instance with your connection data and you're set.


regards

Armin


On 9/26/18 2:11 AM, Alexandr via FreeRDP-devel wrote:
> Good day.
> I have problem with writing rdp client.
> I can't find proper way to pass rdpSetting structure
>
> my code:
>
>       i->instance = freerdp_new();
>       if(!i->instance)
>       {
>               WLog_ERR(TAG, "Failed to create FreeRDP instance");
>               goto error;
>       }
>       i->instance->PreConnect = rdp_pre_connect;
>       i->instance->PostConnect = rdp_post_connect;
>       i->instance->VerifyCertificate = rdp_verify_certificate;
>       i->instance->ReceiveChannelData = rdp_receive_channel_data;
>       i->instance->ContextNew = rdp_context_new;
>       i->instance->ContextFree = rdp_context_free;
>       i->instance->ContextSize = sizeof(my_rdp_context);
>       i->settings = freerdp_settings_new(0);
>       if(!i->settings)
>       {
>               WLog_ERR(TAG, "Failed to create FreeRDP settings");
>               goto error;
>       }
>       if (!freerdp_context_new(i->instance))
>       {
>               WLog_ERR(TAG, "Failed to create FreeRDP context");
>               goto error;
>       }
>       ((my_rdp_context*)i->instance->context)->my_internals =
> internals;
>       i->instance->settings = i->settings;
>       i->settings->instance = i->instance;
>       i->instance->context->settings = i->settings;
>
> ....
> ....
>
>
>       rdpSettings *s = i->instance->settings;
>       
>       s->ServerMode = FALSE;
>       
>       
>       s->TlsSecurity = !(i->my_settings.notls.value);
>       s->ServerHostname = strdup((char*)i->my_settings.host.value);
>       s->ServerPort = i->my_settings.port.value;
>       if(i->my_settings.user.value)
>       {
>               s->Username = strdup((char*)i->my_settings.user.value);
>       }
>       if(i->my_settings.pass.value)
>       {
>               s->Password = strdup((char*)i->my_settings.pass.value);
>       }
>       if(!i->my_settings.user.value && !i->my_settings.pass.value)
>       {
>               /* TODO: desable authentication */
>       }
>       if(i->my_settings.nowallp.value)
>       {
>               s->DisableWallpaper = i->my_settings.nowallp.value;
>               s->PerformanceFlags |= PERF_DISABLE_WALLPAPER;
>       }
>       if(i->my_settings.nowdrag.value)
>       {
>               s->DisableFullWindowDrag = i-
>> my_settings.nowdrag.value;
>               s->PerformanceFlags |= PERF_DISABLE_FULLWINDOWDRAG;
>       }
>       if(i->my_settings.nomani.value)
>       {
>               s->DisableMenuAnims = i->my_settings.nomani.value;
>               s->PerformanceFlags |= PERF_DISABLE_MENUANIMATIONS;
>       }
>       if(i->my_settings.notheme.value)
>       {
>               s->DisableThemes = i->my_settings.notheme.value;
>               s->PerformanceFlags |= PERF_DISABLE_THEMING;
>       }
>       s->NlaSecurity = !(i->my_settings.nonla.value);
>       s->DesktopWidth = i->my_settings.width.value;
>       s->DesktopHeight = i->my_settings.height.value;
>       if(i->my_settings.pcb.value)
>       {
>               s->SendPreconnectionPdu = TRUE;
>               s->PreconnectionBlob = strdup(i-
>> my_settings.pcb.value);
>       }
>       
>       s->SoftwareGdi = TRUE;
>       s->IgnoreCertificate = TRUE;
>       s->NegotiateSecurityLayer = TRUE;
>       s->RdpSecurity = TRUE;
>       s->ExtSecurity = FALSE;
>       s->Authentication = TRUE;
>
>       switch (i->my_settings.perf.value)
>       {
>               case 0:
>                       // LAN
>                       s->PerformanceFlags = PERF_FLAG_NONE;
>                       s->ConnectionType = CONNECTION_TYPE_LAN;
>                       s->AllowFontSmoothing = TRUE;
>                       break;
>               case 1:
>                       // Broadband
>                       s->PerformanceFlags = PERF_DISABLE_WALLPAPER;
>                       s->ConnectionType =
> CONNECTION_TYPE_BROADBAND_HIGH;
>                       break;
>               case 2:
>                       // Modem
>                       s->PerformanceFlags =
>                               PERF_DISABLE_WALLPAPER |
> PERF_DISABLE_FULLWINDOWDRAG |
>                               PERF_DISABLE_MENUANIMATIONS |
> PERF_DISABLE_THEMING;
>                       s->ConnectionType = CONNECTION_TYPE_MODEM;
>                       break;
>       }
>
>
> ....
> ....
>
>
>       freerdp_connect(i->instance);
>
> the problem is what freerdp_connect using rdpSettings from  instance-
>> context->rdp which is not copied from instance->settings, also
> structure definition of rdp_rdp is not exposed for external programs to
> use via api headers, so my questions is how to pass my settings
> properly ?
>
> i can't find any samples or documentation on how to use it, except few
> clients which handling commandline (which is not my usecase)
>
> thx in advance.
>
>
>
> _______________________________________________
> FreeRDP-devel mailing list
> FreeRDP-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/freerdp-devel



_______________________________________________
FreeRDP-devel mailing list
FreeRDP-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freerdp-devel

Reply via email to