2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
21 #include "AppParamParser.h"
22 #include "GUIInfoManager.h"
23 #include "PlayListPlayer.h"
25 #include "Application.h"
26 #include "ApplicationMessenger.h"
27 #include "settings/AdvancedSettings.h"
28 #include "utils/log.h"
30 #include "WIN32Util.h"
33 #include "input/linux/LIRC.h"
35 #ifndef TARGET_WINDOWS
36 #include "linux/XTimeUtils.h"
39 CAppParamParser::CAppParamParser()
44 void CAppParamParser::Parse(const char* argv[], int nArgs)
48 for (int i = 1; i < nArgs; i++)
52 if (strnicmp(argv[i], "-l", 2) == 0 || strnicmp(argv[i], "--lircdev", 9) == 0)
54 // check the next arg with the proper value.
58 if ((argv[next][0] != '-' ) && (argv[next][0] == '/' ))
60 g_RemoteControl.setDeviceName(argv[next]);
65 else if (strnicmp(argv[i], "-n", 2) == 0 || strnicmp(argv[i], "--nolirc", 8) == 0)
66 g_RemoteControl.setUsed(false);
68 if (stricmp(argv[i], "-d") == 0)
72 int sleeptime = atoi(argv[i + 1]);
73 if (sleeptime > 0 && sleeptime < 360)
74 Sleep(sleeptime*1000);
83 void CAppParamParser::DisplayVersion()
85 printf("XBMC Media Center %s\n", g_infoManager.GetVersion().c_str());
86 printf("Copyright (C) 2005-2013 Team XBMC - http://xbmc.org\n");
90 void CAppParamParser::DisplayHelp()
92 printf("Usage: xbmc [OPTION]... [FILE]...\n\n");
93 printf("Arguments:\n");
94 printf(" -d <n>\t\tdelay <n> seconds before starting\n");
95 printf(" -fs\t\t\tRuns XBMC in full screen\n");
96 printf(" --standalone\t\tXBMC runs in a stand alone environment without a window \n");
97 printf("\t\t\tmanager and supporting applications. For example, that\n");
98 printf("\t\t\tenables network settings.\n");
99 printf(" -p or --portable\tXBMC will look for configurations in install folder instead of ~/.xbmc\n");
100 printf(" --legacy-res\t\tEnables screen resolutions such as PAL, NTSC, etc.\n");
102 printf(" -l or --lircdev\tLircDevice to use default is "LIRC_DEVICE" .\n");
103 printf(" -n or --nolirc\tdo not use Lirc, i.e. no remote input.\n");
105 printf(" --debug\t\tEnable debug logging\n");
106 printf(" --version\t\tPrint version information\n");
107 printf(" --test\t\tEnable test mode. [FILE] required.\n");
108 printf(" --settings=<filename>\t\tLoads specified file after advancedsettings.xml replacing any settings specified\n");
109 printf(" \t\t\t\tspecified file must exist in special://xbmc/system/\n");
113 void CAppParamParser::EnableDebugMode()
115 g_advancedSettings.m_logLevel = LOG_LEVEL_DEBUG;
116 g_advancedSettings.m_logLevelHint = LOG_LEVEL_DEBUG;
117 CLog::SetLogLevel(g_advancedSettings.m_logLevel);
120 void CAppParamParser::ParseArg(const CStdString &arg)
122 if (arg == "-fs" || arg == "--fullscreen")
123 g_advancedSettings.m_startFullScreen = true;
124 else if (arg == "-h" || arg == "--help")
126 else if (arg == "-v" || arg == "--version")
128 else if (arg == "--standalone")
129 g_application.SetStandAlone(true);
130 else if (arg == "-p" || arg == "--portable")
131 g_application.EnablePlatformDirectories(false);
132 else if (arg == "--debug")
134 else if (arg == "--legacy-res")
135 g_application.SetEnableLegacyRes(true);
136 else if (arg == "--test")
138 else if (arg.substr(0, 11) == "--settings=")
139 g_advancedSettings.AddSettingsFile(arg.substr(11));
140 else if (arg.length() != 0 && arg[0] != '-')
143 g_application.SetEnableTestMode(true);
144 CFileItemPtr pItem(new CFileItem(arg));
146 m_playlist.Add(pItem);
150 void CAppParamParser::PlayPlaylist()
152 if (m_playlist.Size() > 0)
154 g_playlistPlayer.Add(0, m_playlist);
155 g_playlistPlayer.SetCurrentPlaylist(0);
158 ThreadMessage tMsg = {TMSG_PLAYLISTPLAYER_PLAY, (DWORD) -1};
159 CApplicationMessenger::Get().SendMessage(tMsg, false);