From 05d8623fcc15defa3cd5bcf3ac9d6284af3df201 Mon Sep 17 00:00:00 2001 From: george82 Date: Mon, 28 Mar 2005 12:16:08 +0000 Subject: [PATCH] Implemented the "-upf" command-line parameter. It allows to forces the user 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 | 1 + rfbplayer/UserPixelFormatsDialog.h | 10 +++++-- rfbplayer/rfbplayer.cxx | 47 ++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/rfbplayer/OptionsDialog.h b/rfbplayer/OptionsDialog.h index a673844d..9bf9bbc4 100644 --- a/rfbplayer/OptionsDialog.h +++ b/rfbplayer/OptionsDialog.h @@ -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; diff --git a/rfbplayer/UserPixelFormatsDialog.h b/rfbplayer/UserPixelFormatsDialog.h index 72244e95..fe2ad223 100644 --- a/rfbplayer/UserPixelFormatsDialog.h +++ b/rfbplayer/UserPixelFormatsDialog.h @@ -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: diff --git a/rfbplayer/rfbplayer.cxx b/rfbplayer/rfbplayer.cxx index 3e9357df..dc19857f 100644 --- a/rfbplayer/rfbplayer.cxx +++ b/rfbplayer/rfbplayer.cxx @@ -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 \t- Forces the user defined pixel format for\n" + " \t the session. If 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 \t- Sets playback speed, where 1 is normal speed,\n" " \t is double speed, 0.5 is half speed. Default: 1.0.\n" " -pos \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; -- 2.39.5