client/common: honor RedirectSmartCards, RedirectPrinters
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 28 Apr 2014 01:29:44 +0000 (21:29 -0400)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Mon, 28 Apr 2014 01:29:44 +0000 (21:29 -0400)
channels/smartcard/client/smartcard_main.c
channels/smartcard/client/smartcard_operations.c
client/common/cmdline.c
winpr/libwinpr/smartcard/smartcard_pcsc.c

index 84ee581..abc8238 100644 (file)
@@ -255,7 +255,7 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
 
        smartcard->log = WLog_Get("com.freerdp.channel.smartcard.client");
 
-       WLog_SetLogLevel(smartcard->log, WLOG_DEBUG);
+       //WLog_SetLogLevel(smartcard->log, WLOG_DEBUG);
 
        smartcard->IrpQueue = MessageQueue_New(NULL);
        smartcard->OutstandingIrps = ListDictionary_New(TRUE);
index 191d84a..64f41a2 100644 (file)
@@ -1010,7 +1010,7 @@ void smartcard_irp_device_control(SMARTCARD_DEVICE* smartcard, IRP* irp)
        WLog_Print(smartcard->log, WLOG_DEBUG, "%s (0x%08X) FileId: %d CompletionId: %d",
                        smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, irp->FileId, irp->CompletionId);
 
-#if 1
+#if 0
        printf("%s (0x%08X) FileId: %d CompletionId: %d\n",
                smartcard_get_ioctl_string(ioControlCode, TRUE), ioControlCode, irp->FileId, irp->CompletionId);
 #endif
index 4ce1e1c..50c033b 100644 (file)
@@ -297,6 +297,9 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                if (count < 3)
                        return -1;
 
+               settings->RedirectDrives = TRUE;
+               settings->DeviceRedirection = TRUE;
+
                drive = (RDPDR_DRIVE*) calloc(1, sizeof(RDPDR_DRIVE));
 
                if (!drive)
@@ -311,7 +314,6 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                        drive->Path = _strdup(params[2]);
 
                freerdp_device_collection_add(settings, (RDPDR_DEVICE*) drive);
-               settings->DeviceRedirection = TRUE;
 
                return 1;
        }
@@ -322,21 +324,26 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                if (count < 1)
                        return -1;
 
-               printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
+               settings->RedirectPrinters = TRUE;
+               settings->DeviceRedirection = TRUE;
 
-               if (!printer)
-                       return -1;
+               if (count > 1)
+               {
+                       printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
 
-               printer->Type = RDPDR_DTYP_PRINT;
+                       if (!printer)
+                               return -1;
 
-               if (count > 1)
-                       printer->Name = _strdup(params[1]);
+                       printer->Type = RDPDR_DTYP_PRINT;
 
-               if (count > 2)
-                       printer->DriverName = _strdup(params[2]);
+                       if (count > 1)
+                               printer->Name = _strdup(params[1]);
 
-               freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
-               settings->DeviceRedirection = TRUE;
+                       if (count > 2)
+                               printer->DriverName = _strdup(params[2]);
+
+                       freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
+               }
 
                return 1;
        }
@@ -347,21 +354,26 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                if (count < 1)
                        return -1;
 
-               smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
+               settings->RedirectSmartCards = TRUE;
+               settings->DeviceRedirection = TRUE;
 
-               if (!smartcard)
-                       return -1;
+               if (count > 1)
+               {
+                       smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
 
-               smartcard->Type = RDPDR_DTYP_SMARTCARD;
+                       if (!smartcard)
+                               return -1;
 
-               if (count > 1)
-                       smartcard->Name = _strdup(params[1]);
+                       smartcard->Type = RDPDR_DTYP_SMARTCARD;
 
-               if (count > 2)
-                       smartcard->Path = _strdup(params[2]);
+                       if (count > 1)
+                               smartcard->Name = _strdup(params[1]);
 
-               freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
-               settings->DeviceRedirection = TRUE;
+                       if (count > 2)
+                               smartcard->Path = _strdup(params[2]);
+
+                       freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
+               }
 
                return 1;
        }
@@ -372,6 +384,9 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                if (count < 1)
                        return -1;
 
+               settings->RedirectSerialPorts = TRUE;
+               settings->DeviceRedirection = TRUE;
+
                serial = (RDPDR_SERIAL*) calloc(1, sizeof(RDPDR_SERIAL));
 
                if (!serial)
@@ -386,7 +401,6 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                        serial->Path = _strdup(params[2]);
 
                freerdp_device_collection_add(settings, (RDPDR_DEVICE*) serial);
-               settings->DeviceRedirection = TRUE;
 
                return 1;
        }
@@ -397,6 +411,9 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                if (count < 1)
                        return -1;
 
+               settings->RedirectParallelPorts = TRUE;
+               settings->DeviceRedirection = TRUE;
+
                parallel = (RDPDR_PARALLEL*) calloc(1, sizeof(RDPDR_PARALLEL));
 
                if (!parallel)
@@ -411,7 +428,6 @@ int freerdp_client_add_device_channel(rdpSettings* settings, int count, char** p
                        parallel->Path = _strdup(params[2]);
 
                freerdp_device_collection_add(settings, (RDPDR_DEVICE*) parallel);
-               settings->DeviceRedirection = TRUE;
 
                return 1;
        }
@@ -1861,13 +1877,17 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
                settings->SupportHeartbeatPdu ||
                settings->SupportMultitransport)
        {
-               settings->DeviceRedirection = TRUE; /* these RDP 8 features require rdpdr to be registered */
+               settings->DeviceRedirection = TRUE; /* these RDP8 features require rdpdr to be registered */
        }
 
-       if (settings->RedirectDrives)
+       if (settings->RedirectDrives || settings->RedirectHomeDrive || settings->RedirectSerialPorts
+                       || settings->RedirectSmartCards || settings->RedirectPrinters)
        {
-               settings->DeviceRedirection = TRUE;
+               settings->DeviceRedirection = TRUE; /* All of these features require rdpdr */
+       }
 
+       if (settings->RedirectDrives)
+       {
                if (!freerdp_device_collection_find(settings, "drive"))
                {
                        char* params[3];
@@ -1882,8 +1902,6 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
 
        if (settings->RedirectHomeDrive)
        {
-               settings->DeviceRedirection = TRUE;
-
                if (!freerdp_device_collection_find(settings, "drive"))
                {
                        char* params[3];
@@ -1911,6 +1929,32 @@ int freerdp_client_load_addins(rdpChannels* channels, rdpSettings* settings)
                }
        }
 
+       if (settings->RedirectSmartCards)
+       {
+               RDPDR_SMARTCARD* smartcard;
+
+               smartcard = (RDPDR_SMARTCARD*) calloc(1, sizeof(RDPDR_SMARTCARD));
+
+               if (!smartcard)
+                       return -1;
+
+               smartcard->Type = RDPDR_DTYP_SMARTCARD;
+               freerdp_device_collection_add(settings, (RDPDR_DEVICE*) smartcard);
+       }
+
+       if (settings->RedirectPrinters)
+       {
+               RDPDR_PRINTER* printer;
+
+               printer = (RDPDR_PRINTER*) calloc(1, sizeof(RDPDR_PRINTER));
+
+               if (!printer)
+                       return -1;
+
+               printer->Type = RDPDR_DTYP_PRINT;
+               freerdp_device_collection_add(settings, (RDPDR_DEVICE*) printer);
+       }
+
        if (settings->RedirectClipboard)
        {
                if (!freerdp_static_channel_collection_find(settings, "cliprdr"))
index 419d74f..dfc38f8 100644 (file)
@@ -486,7 +486,7 @@ char* PCSC_ConvertReaderNameToWinSCard(const char* name)
 
        sprintf_s(nameWinSCard, size, "%.*s %d", length, p, index);
 
-       printf("Smart Card Reader Name Alias: %s -> %s\n", p, nameWinSCard);
+       //printf("Smart Card Reader Name Alias: %s -> %s\n", p, nameWinSCard);
 
        return nameWinSCard;
 }