%
% 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 java 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(CHECK_IMAGIC);\
	Make(var,wm_cx,by_value,120);\
	Make(var,wm_cy,by_value,160);\
	Make(var,wm_rotate,by_value,);
	
(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);

CHECK_IMAGIC=\
	Exec(P=`which convert 2> /dev/null|grep convert|grep -v no|wc -l|tr -d " "`;if [ "x$P" = "x1" ]; then true; else $(CfgDir)/Utils/message.sh "ERROR: ImageMagic is not installed"; fi);

Cancel=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=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));\
	Set(popup,show,Loading...);\
	ExecAndSet(image,window,cd $HOME/.anyRemote;echo $(Param)>ar_viewfile.tmp;cat `cat ar_storedir.tmp`/`cat ar_viewfile.tmp`|convert - $(wm_rotate) -resize $(wm_cx)x$(wm_cy) -depth 8 scr.png;echo $HOME/.anyRemote/scr.png);\
	Set(popup,hide);\
	Macro(WINMENU);
	
SHOW2=\
	Set(popup,show,Loading...);\
	ExecAndSet(image,window,sleep 1;cd "`cat $HOME/.anyRemote/ar_storedir.tmp`";cat "`cat $HOME/.anyRemote/ar_viewfile.tmp`"|convert - $(wm_rotate) -resize $(wm_cx)x$(wm_cy) -depth 8 $HOME/.anyRemote/scr.png;echo $HOME/.anyRemote/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,J=`expr $(view_idx) + 1`;echo $J);\
	Exec(ls -1 `cat $HOME/.anyRemote/ar_storedir.tmp`|head -$(view_idx)|tail -1 > $HOME/.anyRemote/ar_viewfile.tmp);\
	Macro(SHOW2);

Previous=\
	Make(var,view_idx,J=`expr $(view_idx) - 1`;echo $J);\
	Exec(ls -1 `cat $HOME/.anyRemote/ar_storedir.tmp`|head -$(view_idx)|tail -1 > $HOME/.anyRemote/ar_viewfile.tmp);\
	Macro(SHOW2);

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

[End]
