%
% anyremote configuration file for to make basic file operations with help of
% GUI of Java client. (Server-mode)
%

% STATUS stable
% TODO handle braces/brackets in file names
% XTEST no
% SOUND no
% ENV no
% FBROWSER v.3i
% ALL_IN_ONE 
% MEDIACENTER files

GuiAppName=FileManager3
GuiAppBinary=true
GuiAppIcon=fileopen.png
GuiAppType=Custom
GuiAppProtocols=Server
GuiAppDesc=Simple file manager. Browsing directory structure with basic file operations.

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Include($(CfgDir)/Utils/aliases-server-fbrowser-v3i.cfg);\
	Set(parameter,debug,on);

(Connect)=\
    Make(var,fm_v3i_list_index,by_value,1);\
    Make(var,fm_v3i_layout_done,by_value,0);\
	Macro(FBROWSER_IC_INIT);\
    Make(mode,file_manager_v3i_init);
    
(Exit)=\
	Macro(FBROWSER_IC_EXIT);

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_general

%InCall($$)=\
%	Make(remote,off);

%EndCall($$)=\
%	Make(remote,on);

UPDATE_MENU=\
	Set(menu,replace,GoTo,File info,Copy,Move,Delete,Make Dir,View,Exec,Go Home);\
	Macro(ALLIN1MENU);\
	Macro(MEDIACENTER_MENU);

SET_INDEX=\
	Set(iconlist,select,$(fm_v3i_list_index));

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]= file_manager_v3i_general_operation : file_manager_v3i_general

FMAN_IC_FILL_LIST2=\
	ExecAndSet(iconlist,add,SAME,\
	           cd "$(fbrowser_dir2)";\
		   ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep '/'| xargs -d '\n' -i echo "folder:"{});
	ExecAndSet(iconlist,add,SAME,\
	           cd "$(fbrowser_dir2)";\
		   ls -F --quoting-style=shell|sed 's/\*//;s/,/\r/g;s/@//;s/$/,/'|grep -v '/'| xargs -d '\n' -i echo "file:"{});

Go To($$)=\
	Make(var,tmpdir,by_value,$(Param));\
	Make(var,fbrowser_dir2,cd "$(fbrowser_dir2)";if [ -d $(tmpdir) ]; then cd $(tmpdir);fi;pwd);\
	Set(iconlist,replace,SAME,folder:..);\
	Macro(FMAN_IC_FILL_LIST2);

Back=\
	Make(mode,file_manager_v3i_init);

Back($$)=\
	Make(mode,file_manager_v3i_init);

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_init : file_manager_v3i_general

(EnterMode)=\
    Set(popup,show,Please wait);\
    Macro(FM3I_SET_LAYOUT,echo $(fm_v3i_layout_done));\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UPDATE_MENU);

FM3I_SET_LAYOUT=\
	Set(layout,3x4);\
	Set(icons,File manager,\
		1,folder,2,fullscreen,3,default,\
		4,default,5,default,6,default,\
		7,default,8,default,9,default,\
		*,question,0,no,#,default);\
	Set(title,Press 1 to enter file browser);\
	Set(status,);\
    Make(var,fm_v3i_layout_done,by_value,1);
	
STORE_INDEX=\
	Make(var,fm_v3i_list_index,by_value,$(Index));
	
Back($$)=\
	Set(list,close);\
	Macro(ALLIN1MENU);\
	Macro(MEDIACENTER_MENU);
	
Back=\
	Set(text,close);\
	Macro(ALLIN1MENU);\
	Macro(MEDIACENTER_MENU);

GoTo($$)=\
	Macro(FBROWSER_IC_GO_TO);

Go Home($$)=\
	Macro(FBROWSER_IC_GO_HOME);

%Push($$) use from aliases-server-fbrowser-v3i.cfg

Cancel=Make(exit);

0=Make(exit);

1=Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UPDATE_MENU);
	
2=Set(fullscreen,toggle);

* *=Set(text,replace,Help, Menu-driven basic\nfile operations.\n1 - enter file manager screen\n2 - toggle fullscreen);

% -----------------------------------------------------------------------

FM3I_DO_OPERATION=\
	Macro(STORE_INDEX);\
	Make(var,fm_v3i_file,by_value,$(Param));\
	Make(mode,file_manager_v3i_$(fm_v3i_operation));

Exec($$)=\
	Make(var,fm_v3i_operation,by_value,exec);\
	Macro(FM3I_DO_OPERATION);

Make Dir($$)=\
	Make(var,fm_v3i_operation,by_value,mkdir);\
	Macro(FM3I_DO_OPERATION);

File info($$)=\
	Make(var,fm_v3i_operation,by_value,info);\
	Macro(FM3I_DO_OPERATION);

View($$)=\
	Make(var,fm_v3i_operation,by_value,view);\
	Macro(FM3I_DO_OPERATION);
    
Copy($$)=\
	Make(var,fm_v3i_operation,by_value,copy);\
	Macro(FM3I_DO_OPERATION);

Move($$)=\
	Make(var,fm_v3i_operation,by_value,move);\
	Macro(FM3I_DO_OPERATION);

Delete($$)=\
	Macro(STORE_INDEX);\
	Make(var,dummy,cd "$(fbrowser_dir)";rm -rf "$(Param)";echo DONE;);\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(SET_INDEX);

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_exec : file_manager_v3i_general_operation

(EnterMode)=\
	Set(editfield,Enter parameters,Parameters,);

Ok($$)=\
	ExecAndSet(text,replace,Results,cd "$(fbrowser_dir)";"$(fbrowser_dir)"/$(fm_v3i_file) $(Param));
	
[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_mkdir : file_manager_v3i_general_operation

(EnterMode)=\
	Set(editfield,Enter name,New Directory,);

Ok($$)=\
	Make(var,dummy,cd "$(fbrowser_dir)";mkdir $(Param);echo DONE;);\
	Make(mode,file_manager_v3i_init);

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_info : file_manager_v3i_general_operation

(EnterMode)=\
	ExecAndSet(text,replace,File info,file "$(fbrowser_dir)"/$(fm_v3i_file));\
	ExecAndSet(text,add,SAME,ls -l "$(fbrowser_dir)"/$(fm_v3i_file));

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_view : file_manager_v3i_general_operation

(EnterMode)=\
	ExecAndSet(text,replace,File View,more "$(fbrowser_dir)"/$(fm_v3i_file));
	
[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_copy : file_manager_v3i_general_operation

(EnterMode)=\
	Make(var,fbrowser_dir2,by_value,$(fbrowser_dir));\
	Set(iconlist,replace,Copy To,folder:..);\
	Macro(FMAN_IC_FILL_LIST2);\
	Set(menu,replace,Go To,Copy To);

Copy To($$)=\
	Make(var,dummy,cp "$(fbrowser_dir)"/$(fm_v3i_file) "$(fbrowser_dir2)"/$(Param);echo DONE;);\
	Make(mode,file_manager_v3i_init);

[ModeEnd]

% -----------------------------------------------------------------------

[Mode]=file_manager_v3i_move : file_manager_v3i_general_operation

(EnterMode)=\
	Make(var,fbrowser_dir2,by_value,$(fbrowser_dir));\
	Set(iconlist,replace,Move To,folder:..);\
	Macro(FMAN_IC_FILL_LIST2);\
	Set(menu,replace,Go To,Move To);

Move To($$)=\
	Make(var,dummy,mv "$(fbrowser_dir)"/$(fm_v3i_file) "$(fbrowser_dir2)"/$(Param);echo DONE;);\
	Make(mode,file_manager_v3i_init);

[ModeEnd]

[End]
