libfreerdp-core: improved capability negotiation
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 25 Jul 2011 16:25:28 +0000 (12:25 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 25 Jul 2011 16:25:28 +0000 (12:25 -0400)
include/freerdp/settings.h
libfreerdp-core/capabilities.c
libfreerdp-core/capabilities.h
libfreerdp-core/connection.c
libfreerdp-core/rdp.c
libfreerdp-core/settings.c
libfreerdp-utils/args.c

index c300129..cdd5389 100644 (file)
@@ -176,6 +176,7 @@ struct rdp_settings
        boolean frame_marker;
        boolean bitmap_cache_v3;
 
+       uint8 received_caps[32];
        uint8 order_support[32];
 
        boolean color_pointer;
@@ -208,19 +209,12 @@ struct rdp_settings
 
        boolean frame_acknowledge;
 
+       uint8* app_name;
        boolean remote_app;
 
-       char app_name[64];
-       int desktop_save;
-       int polygon_ellipse_orders;
-       int off_screen_bitmaps;
-       int triblt;
-       int new_cursors;
-       int mouse_motion;
        int rfx_flags;
        int ui_decode_flags;
-       int use_frame_ack;
-       int software_gdi;
+       boolean mouse_motion;
 };
 typedef struct rdp_settings rdpSettings;
 
index 831342e..49e7b7e 100644 (file)
@@ -816,10 +816,14 @@ void rdp_read_offscreen_bitmap_cache_capability_set(STREAM* s, rdpSettings* sett
 void rdp_write_offscreen_bitmap_cache_capability_set(STREAM* s, rdpSettings* settings)
 {
        uint8* header;
+       uint32 offscreenSupportLevel;
 
        header = rdp_capability_set_start(s);
 
-       stream_read_uint32(s, settings->offscreen_bitmap_cache); /* offscreenSupportLevel (4 bytes) */
+       if (settings->offscreen_bitmap_cache)
+               offscreenSupportLevel = True;
+
+       stream_read_uint32(s, offscreenSupportLevel); /* offscreenSupportLevel (4 bytes) */
        stream_write_uint16(s, settings->offscreen_bitmap_cache_size); /* offscreenCacheSize (2 bytes) */
        stream_write_uint16(s, settings->offscreen_bitmap_cache_entries); /* offscreenCacheEntries (2 bytes) */
 
@@ -1400,7 +1404,7 @@ void rdp_read_demand_active(STREAM* s, rdpSettings* settings)
 
                rdp_read_capability_set_header(s, &length, &type);
                printf("%s Capability Set (0x%02X), length:%d\n", CAPSET_TYPE_STRINGS[type], type, length);
-
+               settings->received_caps[type] = True;
                em = bm + length;
 
                switch (type)
@@ -1575,6 +1579,48 @@ void rdp_write_confirm_active(STREAM* s, rdpSettings* settings)
        rdp_write_color_cache_capability_set(s, settings);
        rdp_write_window_activation_capability_set(s, settings);
 
+       if (settings->offscreen_bitmap_cache)
+       {
+               numberCapabilities++;
+               rdp_write_offscreen_bitmap_cache_capability_set(s, settings);
+       }
+
+       if (settings->received_caps[CAPSET_TYPE_MULTI_FRAGMENT_UPDATE])
+       {
+               numberCapabilities++;
+               rdp_write_multifragment_update_capability_set(s, settings);
+       }
+
+       if (settings->received_caps[CAPSET_TYPE_LARGE_POINTER])
+       {
+               numberCapabilities++;
+               rdp_write_large_pointer_capability_set(s, settings);
+       }
+
+       if (settings->received_caps[CAPSET_TYPE_SURFACE_COMMANDS])
+       {
+               numberCapabilities++;
+               rdp_write_surface_commands_capability_set(s, settings);
+       }
+
+#if 0
+       if (settings->received_caps[CAPSET_TYPE_BITMAP_CODECS])
+       {
+               numberCapabilities++;
+               rdp_write_bitmap_codecs_capability_set(s, settings);
+       }
+
+#endif
+
+       if (settings->received_caps[CAPSET_TYPE_FRAME_ACKNOWLEDGE])
+       {
+               if (settings->frame_acknowledge)
+               {
+                       numberCapabilities++;
+                       rdp_write_frame_acknowledge_capability_set(s, settings);
+               }
+       }
+
        stream_get_mark(s, em);
 
        stream_set_mark(s, lm); /* go back to lengthCombinedCapabilities */
@@ -1598,7 +1644,13 @@ void rdp_send_confirm_active(rdpRdp* rdp)
        rdp_send_pdu(rdp, s, PDU_TYPE_CONFIRM_ACTIVE, MCS_BASE_CHANNEL_ID + rdp->mcs->user_id);
 }
 
-void rdp_read_deactivate_all(STREAM* s, rdpSettings* settings)
+void rdp_recv_deactivate_all(rdpRdp* rdp, STREAM* s)
 {
+       uint16 lengthSourceDescriptor;
+
        printf("Deactivate All PDU\n");
+
+       stream_read_uint32(s, rdp->settings->share_id); /* shareId (4 bytes) */
+       stream_read_uint16(s, lengthSourceDescriptor); /* lengthSourceDescriptor (2 bytes) */
+       stream_seek(s, lengthSourceDescriptor); /* sourceDescriptor (should be 0x00) */
 }
index 466866c..cc2c5ed 100644 (file)
@@ -183,7 +183,6 @@ void rdp_read_demand_active(STREAM* s, rdpSettings* settings);
 void rdp_recv_demand_active(rdpRdp* rdp, STREAM* s, rdpSettings* settings);
 void rdp_write_confirm_active(STREAM* s, rdpSettings* settings);
 void rdp_send_confirm_active(rdpRdp* rdp);
-
-void rdp_read_deactivate_all(STREAM* s, rdpSettings* settings);
+void rdp_recv_deactivate_all(rdpRdp* rdp, STREAM* s);
 
 #endif /* __CAPABILITIES_H */
index 3732ab9..870c881 100644 (file)
@@ -166,8 +166,6 @@ void rdp_recv_server_control_pdu(rdpRdp* rdp, STREAM* s, rdpSettings* settings)
 
        rdp_read_server_control_pdu(s, &action);
 
-       printf("Server Control Action: %s\n", CTRLACTION_STRINGS[action]);
-
        if (action == CTRLACTION_COOPERATE)
        {
                rdp_send_client_control_pdu(rdp, CTRLACTION_REQUEST_CONTROL);
@@ -193,8 +191,6 @@ void rdp_send_client_control_pdu(rdpRdp* rdp, uint16 action)
 
        s = rdp_data_pdu_init(rdp);
 
-       printf("Client Control Action: %s\n", CTRLACTION_STRINGS[action]);
-
        rdp_write_client_control_pdu(s, action);
 
        rdp_send_data_pdu(rdp, s, DATA_PDU_TYPE_CONTROL, rdp->mcs->user_id);
index 72cd35e..864b078 100644 (file)
@@ -239,7 +239,8 @@ void rdp_read_set_error_info_data_pdu(STREAM* s)
 
        stream_read_uint32(s, errorInfo); /* errorInfo (4 bytes) */
 
-       printf("Error Info: 0x%08X\n", errorInfo);
+       if (errorInfo != 0)
+               printf("Error Info: 0x%08X\n", errorInfo);
 }
 
 void rdp_read_data_pdu(rdpRdp* rdp, STREAM* s)
@@ -400,7 +401,7 @@ void rdp_recv(rdpRdp* rdp)
                                break;
 
                        case PDU_TYPE_DEACTIVATE_ALL:
-                               rdp_read_deactivate_all(s, rdp->settings);
+                               rdp_recv_deactivate_all(rdp, s);
                                break;
 
                        case PDU_TYPE_SERVER_REDIRECTION:
index b9e6625..462cd79 100644 (file)
@@ -89,6 +89,7 @@ rdpSettings* settings_new()
                settings->frame_marker = False;
                settings->bitmap_cache_v3 = False;
 
+               settings->offscreen_bitmap_cache = True;
                settings->offscreen_bitmap_cache_size = 7680;
                settings->offscreen_bitmap_cache_entries = 100;
 
index 8cbc56b..a184896 100644 (file)
@@ -172,14 +172,14 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
                }
                else if (strcmp("--no-osb", argv[index]) == 0)
                {
-                       settings->off_screen_bitmaps = 0;
+                       settings->offscreen_bitmap_cache = 0;
                }
                else if (strcmp("--rfx", argv[index]) == 0)
                {
                        settings->rfx_flags = 1;
                        settings->ui_decode_flags = 1;
-                       settings->use_frame_ack = 0;
                        settings->color_depth = 32;
+                       settings->frame_acknowledge = False;
                        settings->performance_flags = PERF_FLAG_NONE;
                }
                else if (strcmp("-m", argv[index]) == 0)
@@ -194,9 +194,8 @@ int freerdp_parse_args(rdpSettings* settings, int argc, char** argv,
                                printf("missing application name\n");
                                return 0;
                        }
-                       strncpy(settings->app_name, argv[index], sizeof(settings->app_name) - 1);
-                       settings->app_name[sizeof(settings->app_name) - 1] = 0;
-                       settings->remote_app = 1;
+                       settings->app_name = (uint8*) xstrdup(argv[index]);
+                       settings->remote_app = True;
                }
                else if (strcmp("-x", argv[index]) == 0)
                {