]> source.dussan.org Git - tigervnc.git/commitdiff
Implemented the "-upf" command-line parameter. It allows to forces the user
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Mon, 28 Mar 2005 12:16:08 +0000 (12:16 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Mon, 28 Mar 2005 12:16:08 +0000 (12:16 +0000)
defined pixel format for the session.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@271 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfbplayer/OptionsDialog.h
rfbplayer/UserPixelFormatsDialog.h
rfbplayer/rfbplayer.cxx

index a673844dbd131207c07b617b79cc6ab43f64f5ef..9bf9bbc43a71e61255292dde6c94ea39792fdd1f 100644 (file)
@@ -102,6 +102,7 @@ protected:
           index = SendMessage(combo, CB_GETCOUNT, 0, 0) - 1;
         }
         SendMessage(combo, CB_SETCURSEL, index, 0);
+        options->pixelFormatIndex = index - 1;
       }
     }
     return false;
index 72244e95c6b9aca75fd61bc511f2360a8cd1a1fd..fe2ad2237094c1dc89a17603fe8bb566da497d85 100644 (file)
@@ -52,8 +52,7 @@ protected:
         if (edit.showDialog(handle)) {
           supportedPF->add(format_name, pf);
           SendMessage(pfList, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)format_name);
-        };
-       (*supportedPF)[15];
+        }
       }
       break;
     case IDC_REMOVE_BUTTON:
@@ -74,6 +73,11 @@ protected:
     case IDC_EDIT_BUTTON:
       {
         int index = SendMessage(pfList, LB_GETCURSEL, 0, 0);
+        if (index == LB_ERR) {
+          MessageBox(handle, "You must select the pixel format for remove.", 
+                     "RfbPlayer", MB_OK | MB_ICONWARNING);
+          return false;
+        }
         PixelFormat *pf = 
           &(supportedPF->operator[](index + supportedPF->getDefaultPFCount())->PF);
         char *format_name = 
@@ -83,7 +87,7 @@ protected:
           SendMessage(pfList, LB_DELETESTRING, index, 0);
           SendMessage(pfList, LB_INSERTSTRING, index, (LPARAM)(LPCTSTR)format_name);
           SendMessage(pfList, LB_SETCURSEL, index, 0);
-        };
+        }
       }
       break;
     default:
index 3e9357df75264013166abb0fce0588b790e3fd73..dc19857f2e90cb9c30964843297803d4a0678320 100644 (file)
@@ -56,6 +56,10 @@ char usage_msg[] =
  "                \t  be - big endian byte order.\n"
  "                \t  The r, g, b component is in any order.\n"
  "                \t  Default: auto detect the pixel format.\n"
+ "  -upf <name>   \t- Forces the user defined pixel format for\n"
+ "                \t  the session. If <name> is empty then application\n"
+ "                \t  shows the list of user defined pixel formats.\n"
+ "                \t  Don't use this option with -pf.\n"
  "  -speed <value>\t- Sets playback speed, where 1 is normal speed,\n"
  "                \t  is double speed, 0.5 is half speed. Default: 1.0.\n"
  "  -pos <ms>     \t- Sets initial time position in the session file,\n"
@@ -1236,6 +1240,7 @@ char *fileName = 0;
 // it is used only for run the player with command-line parameters
 PlayerOptions playerOptions;
 bool print_usage = false;
+bool print_upf_list = false;
 
 bool processParams(int argc, char* argv[]) {
   playerOptions.commandLineParam = true;
@@ -1300,6 +1305,23 @@ bool processParams(int argc, char* argv[]) {
       continue;
     }
 
+    if ((strcasecmp(argv[i], "-upf") == 0) ||
+        (strcasecmp(argv[i], "/upf") == 0) && (i < argc-1)) {
+      if ((i == argc - 1) || (argv[++i][0] == '-')) {
+        print_upf_list = true;
+        return true;
+      }
+      PixelFormatList userPfList;
+      userPfList.readUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH);
+      int index = userPfList.getIndexByPFName(argv[i]);
+      if (index > 0) {
+        playerOptions.autoDetectPF = false;
+        playerOptions.setPF(&userPfList[index]->PF);
+      } else {
+        return false;
+      }
+      continue;
+    }
 
     if ((strcasecmp(argv[i], "-speed") == 0) ||
         (strcasecmp(argv[i], "/speed") == 0) && (i < argc-1)) {
@@ -1353,6 +1375,31 @@ int WINAPI WinMain(HINSTANCE inst, HINSTANCE prevInst, char* cmdLine, int cmdSho
     programUsage();
     return 0;
   }
+  // Show the user defined pixel formats if required
+  if (print_upf_list) {
+    int list_size = 45;
+    char *upf_list = new char[list_size];
+    PixelFormatList userPfList;
+    userPfList.readUserDefinedPF(HKEY_CURRENT_USER, UPF_REGISTRY_PATH);
+    strcpy(upf_list, "The list of the user defined pixel formats:\n");
+    for (int i = userPfList.getDefaultPFCount(); i < userPfList.count(); i++) {
+      if ((list_size - strlen(upf_list) - 1) < 
+          (strlen(userPfList[i]->format_name) + 2)) {
+        char *tmpStr = new char[list_size = 
+          list_size + strlen(userPfList[i]->format_name) + 2];
+        strcpy(tmpStr, upf_list);
+        delete [] upf_list;
+        upf_list = new char[list_size];
+        strcpy(upf_list, tmpStr);
+        delete [] tmpStr;
+      }
+      strcat(upf_list, userPfList[i]->format_name);
+      strcat(upf_list, "\n");
+    }
+    MessageBox(0, upf_list, "RfbPlayer", MB_OK | MB_ICONINFORMATION);
+    delete [] upf_list;
+    return 0;
+  }
 
   // Create the player
   RfbPlayer *player = NULL;