Difference between revisions of "FileSave screen"

From LinuxMCE
Jump to: navigation, search
(How it's implemented)
m
 
(13 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<table width="100%"> <tr><td bgcolor="#FFCFCF">This page was written by Pluto and imported with their permission when LinuxMCE branched off in February, 2007.  In general any information should apply to LinuxMCE.  However, this page should be edited to reflect changes to LinuxMCE and remove old references to Pluto.</td></tr> </table>FileSave screen allows the user to save files on a storage drive (network drive, internal drive, core, etc.), on a private or public folder, to choose a folder or create new ones and to choose a name for the file to save.
+
{| align="right"
 +
  | __TOC__
 +
  |}
 +
FileSave screen allows the user to save files on a storage drive (network drive, internal drive, core, etc.), on a private or public folder, to choose a folder or create new ones and to choose a name for the file to save.
  
 
== How to use it ==
 
== How to use it ==
SCREEN_FileSave has three specific parameters: default user, caption and the command to be executed with the file.
+
SCREEN_FileSave has three specific parameters: default user value, caption and the command to be executed with the file.
  
 
From a DCE project, you will have to include "Gen_Devices/AllScreens.h" and write two lines of code:
 
From a DCE project, you will have to include "Gen_Devices/AllScreens.h" and write two lines of code:
Line 9: Line 12:
  
 
''SendCommand(screen_FileSave);''
 
''SendCommand(screen_FileSave);''
 
  
 
== How it's implemented ==
 
== How it's implemented ==
Line 16: Line 18:
 
The first thing it does is to send a CMD_Get_Default_Ripping_Info command to Media Plugin and get the default name for the file the be saved, the id of the device with most free space, the name of the device and the base folder for it. The information is saved in few member variables: m_sSaveFile_FileName, m_nSaveFile_PK_DeviceDrive, m_sSaveFile_Drive and m_sSaveFile_MountedFolder.
 
The first thing it does is to send a CMD_Get_Default_Ripping_Info command to Media Plugin and get the default name for the file the be saved, the id of the device with most free space, the name of the device and the base folder for it. The information is saved in few member variables: m_sSaveFile_FileName, m_nSaveFile_PK_DeviceDrive, m_sSaveFile_Drive and m_sSaveFile_MountedFolder.
  
Variables use for gui to be substituted with real values are:
+
Variables use for GUI to be substituted with real values are:
  
 
* VARIABLE_Misc_Data_3_CONST (#31) : the name of the device (which includes the device id and the amount of free space in MB)
 
* VARIABLE_Misc_Data_3_CONST (#31) : the name of the device (which includes the device id and the amount of free space in MB)
Line 29: Line 31:
 
* for cbDataGridSelected (method FileSave_GridSelected)
 
* for cbDataGridSelected (method FileSave_GridSelected)
  
Actions:
+
 
 +
Actions for choose object:
 
* When "Choose" button from "Choose Drive" is pressed, the name of the device is saved and a "go back" command is sent.
 
* When "Choose" button from "Choose Drive" is pressed, the name of the device is saved and a "go back" command is sent.
 
* When "Choose" button from "Choose Folder" is pressed, the command attached to the screen is executed using "CMD_Send_Message" command, then Orbiter goes to main menu and FileSave screen's internal status is reseted.
 
* When "Choose" button from "Choose Folder" is pressed, the command attached to the screen is executed using "CMD_Send_Message" command, then Orbiter goes to main menu and FileSave screen's internal status is reseted.
 
* When "Create Directory" button from "Choose Folder" is pressed, SCREEN_GenericKeyboard is used to get the name of the new folder and a command is attach to that screen : a spawn application to be sent to local application server with a makedir.
 
* When "Create Directory" button from "Choose Folder" is pressed, SCREEN_GenericKeyboard is used to get the name of the new folder and a command is attach to that screen : a spawn application to be sent to local application server with a makedir.
 +
* When "Save private" or "Save public" buttons are pressed, Orbiter will determine the path using media type of the current media stream (videos or audio) and using info about the privacy (pluto/data/... or user_<user_id>/data; then orbiter will go to "Choose Folder" design obj.
 +
* When "Choose Drive" or "Choose User" buttons are pressed, Orbiter will save the file name into m_sSaveFile_FileName variable to be able to restore it when needed.
 +
 +
 +
Actions for datagrid selected:
 +
* When a cell from "Choose Drive" 's datagrid is selected, the storage drive id and its name will be saved in m_nSaveFile_PK_DeviceDrive and m_sSaveFile_MountedFolder variables.
 +
* When a cell from "Choose Folder" 's datagrid is selected, the embedded messages from the cell will be sent, repopulating the datagrid with the content of the selected folder or the parent folder. Also, a "Set Text" command is sent to should to use the full path for the selected folder.
 +
 +
 +
For more details, check ScreenHandler's methods : SCREEN_FileSave, FileSave_ObjectSelected and FileSave_GridSelected. ScreenHandler class is located in src/Orbiter/ScreenHandler.h,.cpp folder.
  
 
== Examples ==
 
== Examples ==
* Ripping
+
 
* Saving bookmarks
+
=== Ripping ===
 +
For ripping DVD's, we've attach to "copy disc" button from DVD remote screen a "Goto Screen" command with PK_Screen = 19.
 +
The caption is "<%=T530%>", which tells Orbiter to replace it with the content of the text string id 530.
 +
The command is: <%=!%> <%=V-106%> 1 337 17 <%=U%> 50 "<%=17%>" 233 <%=45%> 234 <%=9%>, where:
 +
* <%=!%> will be replaced by orbiter with the id of the orbiter device
 +
* <%=V-106%> will be replaced by orbiter with the id of media plugin
 +
* 1 is the message type : command
 +
* 337 is the id the "rip disk" command
 +
* 50 is the id of the command parameter of file name
 +
* "<%=17%>" will be replaced by orbiter with the content of variable VARIABLE_Seek_Value_CONST (which will contain the file name)
 +
* 233 is for device id
 +
* <%=45%> will be replaced by orbiter with the content of variable VARIABLE_Device_List_CONST
 +
* 234 is for full path
 +
* <%=9%> will be replaced by orbiter with the content of variable VARIABLE_Path_CONST
 +
 
 +
 
 +
=== Saving bookmarks ===
 +
 
 +
From Media_Plugin, a SCREEN_FileSave command is sent to orbiter and it will contain the following command:
 +
 
 +
 
 +
''int PK_Screen = pMediaStream->GetRemoteControlScreen(pMessage->m_dwPK_Device_From);''
 +
 
 +
''string sCmdToRenameBookmark = ''
 +
''"<%=!%> -300 1 741 159 " + StringUtils::itos(PK_Screen) + ''
 +
''"\n<%=!%> <%=V-106%> 1 411 5 \"<%=17%>\" 129 " + StringUtils::itos(pRow_Bookmark->PK_Bookmark_get()) +''
 +
''" " + StringUtils::ltos(COMMANDPARAMETER_DriveID_CONST) + " <%=" + StringUtils::ltos(VARIABLE_Device_List_CONST) + "%>";''
 +
 
 +
 
 +
There are here actually two commands attached, separated by a "\n":
 +
* A go to screen to the remote
 +
* A rename bookmark command where parameter #5 (Value To Assign) will contain the file name.
 +
[[Category: Programmer's Guide]]

Latest revision as of 05:27, 29 October 2007

FileSave screen allows the user to save files on a storage drive (network drive, internal drive, core, etc.), on a private or public folder, to choose a folder or create new ones and to choose a name for the file to save.

How to use it

SCREEN_FileSave has three specific parameters: default user value, caption and the command to be executed with the file.

From a DCE project, you will have to include "Gen_Devices/AllScreens.h" and write two lines of code:

DCE::SCREEN_FileSave screen_FileSave(m_dwPK_Device,pMessage->m_dwPK_Device_From, "", "Please type a name for the file", sCommand);

SendCommand(screen_FileSave);

How it's implemented

Orbiter has a screen handler called SCREEN_FileSave and implemented in ScreenHandler class. The first thing it does is to send a CMD_Get_Default_Ripping_Info command to Media Plugin and get the default name for the file the be saved, the id of the device with most free space, the name of the device and the base folder for it. The information is saved in few member variables: m_sSaveFile_FileName, m_nSaveFile_PK_DeviceDrive, m_sSaveFile_Drive and m_sSaveFile_MountedFolder.

Variables use for GUI to be substituted with real values are:

  • VARIABLE_Misc_Data_3_CONST (#31) : the name of the device (which includes the device id and the amount of free space in MB)
  • VARIABLE_Misc_Data_4_CONST (#33) : relative folder to base path
  • VARIABLE_Device_List_CONST (#45) : the id of the storage device
  • VARIABLE_Misc_Data_5_CONST (#43) : base path for device
  • VARIABLE_Seek_Value_CONST (#17) : the file name


The screen has two registered interceptors:

  • for cbObjectSelected (method FileSave_ObjectSelected)
  • for cbDataGridSelected (method FileSave_GridSelected)


Actions for choose object:

  • When "Choose" button from "Choose Drive" is pressed, the name of the device is saved and a "go back" command is sent.
  • When "Choose" button from "Choose Folder" is pressed, the command attached to the screen is executed using "CMD_Send_Message" command, then Orbiter goes to main menu and FileSave screen's internal status is reseted.
  • When "Create Directory" button from "Choose Folder" is pressed, SCREEN_GenericKeyboard is used to get the name of the new folder and a command is attach to that screen : a spawn application to be sent to local application server with a makedir.
  • When "Save private" or "Save public" buttons are pressed, Orbiter will determine the path using media type of the current media stream (videos or audio) and using info about the privacy (pluto/data/... or user_<user_id>/data; then orbiter will go to "Choose Folder" design obj.
  • When "Choose Drive" or "Choose User" buttons are pressed, Orbiter will save the file name into m_sSaveFile_FileName variable to be able to restore it when needed.


Actions for datagrid selected:

  • When a cell from "Choose Drive" 's datagrid is selected, the storage drive id and its name will be saved in m_nSaveFile_PK_DeviceDrive and m_sSaveFile_MountedFolder variables.
  • When a cell from "Choose Folder" 's datagrid is selected, the embedded messages from the cell will be sent, repopulating the datagrid with the content of the selected folder or the parent folder. Also, a "Set Text" command is sent to should to use the full path for the selected folder.


For more details, check ScreenHandler's methods : SCREEN_FileSave, FileSave_ObjectSelected and FileSave_GridSelected. ScreenHandler class is located in src/Orbiter/ScreenHandler.h,.cpp folder.

Examples

Ripping

For ripping DVD's, we've attach to "copy disc" button from DVD remote screen a "Goto Screen" command with PK_Screen = 19. The caption is "<%=T530%>", which tells Orbiter to replace it with the content of the text string id 530. The command is: <%=!%> <%=V-106%> 1 337 17 <%=U%> 50 "<%=17%>" 233 <%=45%> 234 <%=9%>, where:

  • <%=!%> will be replaced by orbiter with the id of the orbiter device
  • <%=V-106%> will be replaced by orbiter with the id of media plugin
  • 1 is the message type : command
  • 337 is the id the "rip disk" command
  • 50 is the id of the command parameter of file name
  • "<%=17%>" will be replaced by orbiter with the content of variable VARIABLE_Seek_Value_CONST (which will contain the file name)
  • 233 is for device id
  • <%=45%> will be replaced by orbiter with the content of variable VARIABLE_Device_List_CONST
  • 234 is for full path
  • <%=9%> will be replaced by orbiter with the content of variable VARIABLE_Path_CONST


Saving bookmarks

From Media_Plugin, a SCREEN_FileSave command is sent to orbiter and it will contain the following command:


int PK_Screen = pMediaStream->GetRemoteControlScreen(pMessage->m_dwPK_Device_From);

string sCmdToRenameBookmark = "<%=!%> -300 1 741 159 " + StringUtils::itos(PK_Screen) + "\n<%=!%> <%=V-106%> 1 411 5 \"<%=17%>\" 129 " + StringUtils::itos(pRow_Bookmark->PK_Bookmark_get()) + " " + StringUtils::ltos(COMMANDPARAMETER_DriveID_CONST) + " <%=" + StringUtils::ltos(VARIABLE_Device_List_CONST) + "%>";


There are here actually two commands attached, separated by a "\n":

  • A go to screen to the remote
  • A rename bookmark command where parameter #5 (Value To Assign) will contain the file name.