%
% anyremote configuration file for image viewing on the screen of cellphone (Server-mode)
% prerequisites: ImageMagic
%

% STATUS stable
% XTEST no
% SOUND no
% ENV no
% FBROWSER v.3i

GuiAppName=ImageViewer
GuiAppIcon=redo.png
GuiAppType=Custom
GuiAppBinary=true
GuiAppProtocols=Server
GuiAppDesc=Allows to view images from PC on the phone screen. Beware: Can cause J2ME client crash on some Nokia's and Samsung's

[Protocol]=Server

(Init)=\
	Include($(CfgDir)/Utils/aliases-server.cfg);\
	Include($(CfgDir)/Utils/aliases-server-fbrowser-v3i.cfg);\
	Macro(FBROWSER_IC_INIT);\
	Macro(TEST_IMAGEMAGIC);\
	Make(var,wm_cx,by_value,120);\
	Make(var,wm_cy,by_value,160);\
	Make(var,wm_rotate,by_value,);

(Exit)=\
	Macro(FBROWSER_IC_EXIT);
	
(Connect)=\
	Set(parameter,debug,on);\
	Set(icons,ImageViewer,\
		1,folder,2,plus,3,default,\
		4,default,5,default,6,default,\
		7,default,8,default,9,default,\
		*,question,0,no,#,default);\
	Set(title,);\
	Set(status,);\
	Get(screen_size);\
	Set(image,nocursor);

Cancel=\
	Make(exit);

Back=\
	Set(text,close);\
	Set(image,close);\
	Set(menu,replace,);
	
Back($$)=\
	Set(list,close);
	
UpdateMenu=\
	Set(menu,replace,GoTo,Open,Go Home);

Open($$)=\
	Make(var,view_idx,echo $(Index));\
	Macro(SHOW);
	
GoTo($$)=\
	Macro(FBROWSER_IC_GO_TO);
	
Go Home($$)=\
	Macro(FBROWSER_IC_GO_HOME);
	
%Push($$) use from aliases-server-fbrowser-v3i.cfg

1=\
    Macro(FBROWSER_IC_FILL_LIST);\
    Macro(UpdateMenu);

2=\
    Set(fullscreen,toggle);\
    Get(screen_size);

9=\
    Set(image,show);\
    Macro(WINMENU);

* *=\
    Set(text,replace,Help, Image viewer.\n1 - File browser\n2 - Toggle Fullscreen);Set(menu,replace,);
0=\
    Make(exit);

% sure that SizeY will be second one
SizeX($$)=\
	Make(var,wm_cx,by_value,$(Index));
	
SizeY($$)=\
	Make(var,wm_cy,by_value,$(Index));

% Android gestures support
ImageSlideLeft=\
	Macro(Next);
	
ImageSlideRight=\
	Macro(Previous);

WINMENU=\
	Set(menu,replace,Next,Previous,Rotate,Update,List);

SHOW=\
	Make(var,view_idx,echo $(Index));\
	Make(var,view_file,by_value,$(Param));\
	Macro(SHOW2);
	
SHOW2=\
	Set(popup,show,Loading...);\
	ExecAndSet(image,window,\
	     cd "$(fbrowser_dir)";\
	     cat "$(view_file)"|convert - $(wm_rotate) \
	         -resize $(wm_cx)x$(wm_cy) \
		 -depth 8 $(TmpDir)/scr.png;\
	     echo $(TmpDir)/scr.png);\
	Set(popup,hide);\
	Macro(WINMENU);

Update=Macro(SHOW2);

Rotate=\
	Make(var,wm_rotate,if [ "x$(wm_rotate)" = "x" ]; then echo "-rotate 90"; else echo ""; fi);\
	Macro(SHOW2);

Next=\
	Make(var,view_idx,expr $(view_idx) + 1);\
	Exec(echo d1);\
	Make(var,view_file,ls -1 "$(fbrowser_dir)"|head -$(view_idx)|tail -1);\
	Exec(echo e1);\
	Macro(SHOW2);

Previous=\
	Make(var,view_idx,J=`expr $(view_idx) - 1`;echo $J);\
	Make(var,view_file,ls -1 "$(fbrowser_dir)"|head -$(view_idx)|tail -1);\
	Macro(SHOW2);

List=\
	Macro(FBROWSER_IC_FILL_LIST);\
	Macro(UpdateMenu);

[End]
