Skip to content

Instantly share code, notes, and snippets.

@bertrandom
Created December 15, 2010 05:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bertrandom/741665 to your computer and use it in GitHub Desktop.
Save bertrandom/741665 to your computer and use it in GitHub Desktop.
Boxee Box Remote API
int CXbmcHttp::xbmcCommand(const CStdString &parameter)
{
if (shuttingDown)
return -1;
int numParas, retVal=false;
CStdString command, paras[MAX_PARAS];
numParas = splitParameter(parameter, command, paras, ";");
if (parameter.length()<300)
CLog::Log(LOGDEBUG, "HttpApi Start command: %s paras: %s", command.c_str(), parameter.c_str());
else
CLog::Log(LOGDEBUG, "HttpApi Start command: %s paras: [not recorded]", command.c_str());
tempSkipWebFooterHeader=false;
command=command.ToLower();
if (numParas>=0)
{
// TMP - For debug //
CStdString par = "";
for(int k=0; k<numParas ; k++)
{
par += "<";
par += paras[k];
par += ">";
}
CLog::Log(LOGDEBUG,"CXbmcHttp::BoxeeGetMediaItems - Enter function with [parameter=%s]. After split [command=%s][ParamsVec=%s][numParas=%d] (ipc)",parameter.c_str(),command.c_str(),par.c_str(),numParas);
/////////
#if 0
if (command == "clearplaylist") retVal = xbmcClearPlayList(numParas, paras);
else if (command == "addtoplaylist") retVal = xbmcAddToPlayList(numParas, paras);
else if (command == "playfile")
{
retVal = xbmcPlayerPlayFile(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=playfile]. Call xbmcPlayerPlayFile() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if (command == "addtoplaylistfromdb") retVal = xbmcAddToPlayListFromDB(numParas, paras);
#endif
if (command == "pause") retVal = xbmcAction(numParas, paras,1);
else if (command == "stop") retVal = xbmcAction(numParas, paras,2);
else if (command == "playnext") retVal = xbmcAction(numParas, paras,3);
else if (command == "playprev") retVal = xbmcAction(numParas, paras,4);
#if 0
else if (command == "rotate") retVal = xbmcAction(numParas, paras,5);
else if (command == "move") retVal = xbmcAction(numParas, paras,6);
else if (command == "zoom") retVal = xbmcAction(numParas, paras,7);
#endif
else if (command == "restart") retVal = xbmcExit(1);
else if (command == "shutdown") retVal = xbmcExit(2);
else if (command == "exit") retVal = xbmcExit(3);
else if (command == "reset") retVal = xbmcExit(4);
else if (command == "restartapp") retVal = xbmcExit(5);
else if (command == "getcurrentlyplaying") retVal = xbmcGetCurrentlyPlaying(numParas, paras);
#if 0
else if (command == "getxbeid") retVal = xbmcGetXBEID(numParas, paras);
else if (command == "getxbetitle") retVal = xbmcGetXBETitle(numParas, paras);
else if (command == "getshares") retVal = xbmcGetSources(numParas, paras);
else if (command == "getdirectory") retVal = xbmcGetDirectory(numParas, paras);
else if (command == "getmedialocation") retVal = xbmcGetMediaLocation(numParas, paras);
else if (command == "getmediaitems")
{
retVal = BoxeeGetMediaItems(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=getmediaitems]. Call BoxeeGetMediaItems() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
#endif
else if(command == "getthumbnail")
{
retVal = BoxeeGetThumbnail(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=getthumbnail]. Call BoxeeGetThumbnail() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if(command == "getkeyboardtext")
{
retVal = BoxeeGetKeyboardText(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=getkeyboardtext]. Call BoxeeGetKeyboardText() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if(command == "isbrowsermouseactive")
{
retVal = BoxeeIsBrowserMouseActive(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=isbrowsermouseactive]. Call BoxeeIsBrowserMouseActive() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if(command == "addmediasource")
{
retVal = BoxeeAddMediaSource(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=addmediasource]. Call BoxeeAddMediaSource() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if(command == "removemediasource")
{
retVal = BoxeeRemoveMediaSource(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=addmediasource]. Call BoxeeRemoveMediaSource() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
#if 0
else if (command == "gettagfromfilename") retVal = xbmcGetTagFromFilename(numParas, paras);
else if (command == "getcurrentplaylist") retVal = xbmcGetCurrentPlayList();
else if (command == "setcurrentplaylist") retVal = xbmcSetCurrentPlayList(numParas, paras);
else if (command == "getplaylistcontents") retVal = xbmcGetPlayListContents(numParas, paras);
else if (command == "getplaylistlength") retVal = xbmcGetPlayListLength(numParas, paras);
else if (command == "removefromplaylist") retVal = xbmcRemoveFromPlayList(numParas, paras);
else if (command == "setplaylistsong") retVal = xbmcSetPlayListSong(numParas, paras);
else if (command == "getplaylistsong") retVal = xbmcGetPlayListSong(numParas, paras);
else if (command == "playlistnext") retVal = xbmcPlayListNext();
else if (command == "playlistprev") retVal = xbmcPlayListPrev();
#endif
else if (command == "getmusiclabel") retVal = xbmcGetMusicLabel(numParas, paras);
else if (command == "getvideolabel") retVal = xbmcGetVideoLabel(numParas, paras);
else if (command == "getpercentage") retVal = xbmcGetPercentage();
else if (command == "seekpercentage") retVal = xbmcSeekPercentage(numParas, paras, false);
else if (command == "seekpercentagerelative") retVal = xbmcSeekPercentage(numParas, paras, true);
else if (command == "setvolume") retVal = xbmcSetVolume(numParas, paras);
else if (command == "getvolume") retVal = xbmcGetVolume();
else if (command == "mute") retVal = xbmcMute();
else if (command == "setplayspeed") retVal = xbmcSetPlaySpeed(numParas, paras);
else if (command == "getplayspeed") retVal = xbmcGetPlaySpeed();
else if (command == "filedownload") retVal = xbmcGetThumb(numParas, paras, false);
else if (command == "getthumbfilename") retVal = xbmcGetThumbFilename(numParas, paras);
#if 0
else if (command == "lookupalbum") retVal = xbmcLookupAlbum(numParas, paras);
else if (command == "choosealbum") retVal = xbmcChooseAlbum(numParas, paras);
else if (command == "filedownloadfrominternet") retVal = xbmcDownloadInternetFile(numParas, paras);
else if (command == "filedelete") retVal = xbmcDeleteFile(numParas, paras);
else if (command == "filecopy") retVal = xbmcCopyFile(numParas, paras);
else if (command == "filesize") retVal = xbmcFileSize(numParas, paras);
#endif
else if (command == "getmoviedetails") retVal = xbmcGetMovieDetails(numParas, paras);
#if 0
else if (command == "showpicture") retVal = xbmcShowPicture(numParas, paras);
#endif
else if (command == "sendkey")
{
retVal = xbmcSetKey(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=sendkey]. Call xbmcSetKey() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if (command == "sendunicodechar")
{
retVal = BoxeeSetUnicodeChar(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=sendunicodechar]. Call BoxeeSetUnicodeChar() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if (command == "keyrepeat") retVal = xbmcSetKeyRepeat(numParas, paras);
#if 0
else if (command == "fileexists") retVal = xbmcFileExists(numParas, paras);
else if (command == "fileupload") retVal = xbmcSetFile(numParas, paras);
#endif
else if (command == "getguistatus") retVal = xbmcGetGUIStatus();
#if 0
else if (command == "execbuiltin") retVal = xbmcExecBuiltIn(numParas, paras);
else if (command == "config") retVal = xbmcConfig(numParas, paras);
else if (command == "help") retVal = xbmcHelp();
else if (command == "getsysteminfo") retVal = xbmcGetSystemInfo(numParas, paras);
else if (command == "getsysteminfobyname") retVal = xbmcGetSystemInfoByName(numParas, paras);
else if (command == "addtoslideshow") retVal = xbmcAddToSlideshow(numParas, paras);
else if (command == "clearslideshow") retVal = xbmcClearSlideshow();
else if (command == "playslideshow") retVal = xbmcPlaySlideshow(numParas, paras);
else if (command == "getslideshowcontents") retVal = xbmcGetSlideshowContents();
else if (command == "slideshowselect") retVal = xbmcSlideshowSelect(numParas, paras);
else if (command == "getcurrentslide") retVal = xbmcGetCurrentSlide();
else if (command == "getguisetting") retVal = xbmcGUISetting(numParas, paras);
else if (command == "setguisetting") retVal = xbmcGUISetting(numParas, paras);
else if (command == "takescreenshot") retVal = xbmcTakeScreenshot(numParas, paras);
else if (command == "getguidescription") retVal = xbmcGetGUIDescription();
else if (command == "setautogetpicturethumbs") retVal = xbmcAutoGetPictureThumbs(numParas, paras);
else if (command == "setresponseformat") retVal = xbmcSetResponseFormat(numParas, paras);
#endif
else if (command == "querymusicdatabase") retVal = xbmcQueryMusicDataBase(numParas, paras);
else if (command == "queryvideodatabase") retVal = xbmcQueryVideoDataBase(numParas, paras);
#if 0
else if (command == "execmusicdatabase") retVal = xbmcExecMusicDataBase(numParas, paras);
else if (command == "execvideodatabase") retVal = xbmcExecVideoDataBase(numParas, paras);
else if (command == "broadcast") retVal = xbmcBroadcast(numParas, paras);
else if (command == "setbroadcast") retVal = xbmcSetBroadcast(numParas, paras);
else if (command == "getbroadcast") retVal = xbmcGetBroadcast();
#endif
else if (command == "action") retVal = xbmcOnAction(numParas, paras);
#if 0
else if (command == "getrecordstatus") retVal = xbmcRecordStatus(numParas, paras);
else if (command == "webserverstatus")
{
retVal = xbmcWebServerStatus(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=webserverstatus]. Call xbmcWebServerStatus() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
else if (command == "setloglevel") retVal = xbmcSetLogLevel(numParas, paras);
else if (command == "getloglevel") retVal = xbmcGetLogLevel();
//only callable internally
else if (command == "broadcastlevel")
{
retVal = xbmcBroadcast(paras[0], atoi(paras[1]));
retVal = 0;
}
//Old command names
else if (command == "deletefile") retVal = xbmcDeleteFile(numParas, paras);
else if (command == "copyfile") retVal = xbmcCopyFile(numParas, paras);
else if (command == "downloadinternetfile") retVal = xbmcDownloadInternetFile(numParas, paras);
#endif
else if (command == "getthumb") retVal = xbmcGetThumb(numParas, paras, true);
#if 0
else if (command == "guisetting") retVal = xbmcGUISetting(numParas, paras);
else if (command == "setfile") retVal = xbmcSetFile(numParas, paras);
else if (command == "setkey")
{
retVal = xbmcSetKey(numParas, paras);
CLog::Log(LOGDEBUG,"CXbmcHttp::xbmcCommand - In if [command=%s=setkey]. Call xbmcSetKey() returned [retVal=%d] (bgmi)",command.c_str(),retVal);
}
#endif
else
retVal = SetResponse(openTag+"Error:Unknown command");
}
else if (numParas==-2)
retVal = SetResponse(openTag+"Error:Too many parameters");
else
retVal = SetResponse(openTag+"Error:Missing command");
//relinquish the remainder of time slice
Sleep(0);
//CLog::Log(LOGDEBUG, "HttpApi Finished command: %s", command.c_str());
return retVal;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment