@VERSION 7,0
@APPTITLE "IvoRSS"
@APPVERSION "$VER: IvoRSS 1.1 (24.7.22)"
@APPCOPYRIGHT "© 2022, Aleksei Gerasimov"
@APPAUTHOR "Aleksei Gerasimov"
@APPDESCRIPTION "Simple RSS reader"
@APPIDENTIFIER "ivorss"
@REQUIRE "muiroyale", {Version=1, Revision=7}
@REQUIRE "hurl"
@REQUIRE "xmlparser"
@DISPLAY {Hidden=True}
; There is some bug with Czech
;@CATALOG "IvoRSS", {Link=False}
@FILE 1, "AppWindow.xml"
; Generates default feeds
; and puts to feeds.json
;@INCLUDE "feeds.hws"
@INCLUDE "feedsdata.hws"
@INCLUDE "feedtree.hws"
@INCLUDE "lurk.hws"
@INCLUDE "IvoR.hws"
@INCLUDE "textfield.hws"
@BRUSH 1, "128px-Feed-icon.png", {LoadAlpha=True, ScaleHeight=32, ScaleWidth=32}
ChannelIconBrush = 1
PleaseStop = True
AllowImages = True ; Later will be set up in p_StartUpLoading()
UseDefaultDownloader = False ; Later will be set up in p_StartUpLoading()
;Width=#KEEPASPRAT
/*
** Handles all incoming events
Action: Initialized to "MUIRoyale".
Class: Contains the name of the MUI class this event comes from, e.g.
"Cycle".
Attribute:
Contains the name of the class attribute that has triggered the
event, e.g. "Active".
ID: Contains the ID of the MUI object that triggered this event, e.g.
"mycycle".
TriggerValue:
Contains the current value of the attribute that triggered this
event. You could also find this out by doing a mui.Get() on the
object but it is more convenient to get the current value directly
to your event callback.
MUIUserData:
If the object was assigned certain userdata, it will be passed to
the event handler callback in this tag. See Notify.UserData for
details.
NotifyData:
If the object was assigned certain notify data, it will be passed
to the event handler callback in this tag. See Notify.NotifyData
for details.
*/
Function p_MUIEvent(msg)
DebugPrint(msg.Action, " event!",
" Class:", msg.Class,
" Attribute:", msg.Attribute,
" ID:", msg.ID,
" TriggerValue:", msg.TriggerValue)
;" MUIUserData:", IIf(HaveItem(msg, "MUIUserData"), msg.MUIUserData, ""),
;" NotifyData:", msg.NotifyData)
Switch msg.Class
Case "Window":
Switch msg.Attribute
Case "CloseRequest":
Switch msg.ID
Case "win":
p_SaveSettings()
End
Case "metawin":
mui.Set("metawin", "open", False)
EndSwitch
EndSwitch
Case "Menuitem":
Switch msg.ID
Case "menu_about":
Local reqtext$ = "\27c\27b IvoRSS 1.1 \n\27n Simple RSS client"
If mui.Request("About", reqtext$, "Open repository|*OK") Then OpenURL("http://rocketgit.com/iam-git/IvoRSS")
Case "menu_about_mui":
mui.DoMethod("app", "AboutMUI")
Case "menu_about_muiroyale":
mui.DoMethod("app", "AboutMUIRoyale")
Case "menu_quit":
p_SaveSettings()
End
Case "menu_muisettings":
mui.DoMethod("app", "OpenConfigWindow")
Case "rssi_copy":
p_CopyIcon()
Case "rsst_copy":
p_CopyContents("channel_title", "Channel title")
Case "rssd_copy":
p_CopyContents("channel_description", "Channel description")
Case "rsst_copyurl":
p_CopyContents("channel_link", "Channel link")
Case "artt_copyauthor":
p_CopyContents("item_author", "E-mail")
Case "artt_copytitle":
p_CopyContents("item_title", "Title")
Case "artt_copyurl":
p_CopyContents("item_link", "URL")
Case "art_copy":
p_CopyText()
Case "menu_save":
FallThrough
Case "fdtm_save":
p_SaveSettings()
Case "menu_lurk":
FallThrough
Case "fdtm_lurk":
mui.Set("metawin", "open", True)
Case "menu_addgroup":
FallThrough
Case "fdtm_addgroup":
p_CreateGroup()
Case "menu_add":
FallThrough
Case "fdtm_add":
p_AddFeedRequest()
Case "menu_hide":
FallThrough
Case "fdtm_hide":
p_HideFeeds()
Case "menu_expand":
FallThrough
Case "fdtm_expand":
p_ExpandFeeds()
Case "menu_fetchall":
FallThrough
Case "fdtm_fetchall":
p_FetchAll()
Case "fdtm_fetch":
p_FetchCurrent()
Case "fdtm_remove":
p_RemoveCurrent()
Case "fdtm_copyurl":
p_CopyTreeURL()
Case "artl_showsource":
p_ShowSource()
EndSwitch
Case "Listtree":
Switch msg.Attribute
Case "DoubleClick":
;č Skupiny nemůžou získat dvojitý klik, jen se otevřou-zavřou
;č takže jdeme rovnou stahovat
p_FetchCurrent()
Case "Active":
p_ShowCurrent()
EndSwitch
Case "Listview":
Switch msg.ID
Case "articles":
IvoR:ShowArticle(msg.TriggerValue)
Case "foundfeeds":
lurk:AddFromlist("Active")
EndSwitch
Case "Text":
If msg.TriggerValue = 0 Then IvoR:OpenLink(msg.ID)
Case "Button":
Switch msg.ID
Case "reqclosebtn":
mui.Set("metawin", "open", False)
Case "reqaddbtn":
lurk:AddSelected()
Case "lurkbtn":
mui.Set("metawin", "open", True)
Case "addbtn":
p_AddFeedRequest()
Case "fetchbtn":
p_FetchCurrent()
Case "fetchallbtn":
p_FetchAll()
Case "stopbtn":
p_Unlock()
Case "herewegobtn":
p_StartLurk()
Case "stoplurkbtn":
lurk.PleaseStop = True
EndSwitch
EndSwitch
EndFunction
;č že FFS prý podporovala
;č jména souborů jen do 31 znaků
Function p_GetFileID(feedid$)
Return(LeftStr(MD5Str(feedid$), 26))
EndFunction
Function p_GetXMLname(feedid$)
Return("Feeds/"..p_GetFileID(feedid$)..".xml")
EndFunction
Function p_GetLogoName(feedid$, extension$)
Return("Feeds/"..p_GetFileID(feedid$).."." .. extension$)
EndFunction
/* From Hollywood docs:
Action: #DOWNLOADFILE_STATUS
Count: Contains the number of bytes that have already been downloaded.
Total: Contains the size of the file being downloaded.
UserData: Contains the value you passed in the "userdata" argument.
The callback function of type #DOWNLOADFILE_STATUS should normally return FALSE. If it returns TRUE, the download operation will be aborted.*/
Function p_callback(t)
If t.Action = #DOWNLOADFILE_STATUS
mui.Set("status", "Contents",
"Downloading (" .. t.Count .. "/" .. t.Total .. ") " .. t.UserData
)
CheckEvents() ; keep MUI responsive
Return(PleaseStop)
EndIf
EndFunction
;č stáhnout soubor
Function p_Download(url$, filename$)
Local err_code, _empty_str$, count = ?DownloadFile(url$,
{File=filename$, Adapter = "hurl", Fail404=True, Encoded=True},
p_callback, url$)
p_Replay(err_code, count .. "bytes from " .. url$ .. " transmitted")
CheckEvents() ; keep MUI even more responsive
Return(err_code)
EndFunction
/*
Function p_Replay(err_code, msg$)
If err_code = #ERR_NONE
mui.Set("status", "Contents", msg$)
Else
mui.Set("status", "Contents", "\27b" .. GetErrorName(err_code))
EndIf
EndFunction
*/
Function p_Replay(err_code, msg$)
mui.Set("status", "Contents",
IIf(err_code = #ERR_NONE, msg$, "\27b" .. GetErrorName(err_code)))
EndFunction
Function p_CopyIcon()
err_code = ?SetClipboard(#CLIPBOARD_IMAGE, ChannelIconBrush)
p_Replay(err_code, "Icon is copied")
EndFunction
Function p_CopyContents(source_id$, source_desc$)
err_code = ?SetClipboard(#CLIPBOARD_TEXT, mui.Get(source_id$, "Contents"))
p_Replay(err_code, source_desc$ .. " is copied")
EndFunction
Function p_CopyText()
err_code = ?SetClipboard(#CLIPBOARD_TEXT, mui.Get("textfield", "Text"))
p_Replay(err_code, "Text is copied")
EndFunction
Function p_StartUpLoading()
Local t, n, console = GetCommandLine()
For i, v In IPairs(t) ;č tam jsou pouze číselné indexy. Možno.
Switch UpperStr(v["arg"])
Case "DONOTLOADIMAGES":
AllowImages = False
Case "USEDEFAULTDOWNLOADER":
UseDefaultDownloader = True
EndSwitch
Next
; default feeds are generated by feeds.hws
Local err_code, s$, _len = ?FileToString("feeds.json")
p_Replay(err_code, "Program started")
err_code = ?p_FillListTree("feedtree", DeserializeTable(s$))
p_Replay(err_code, "Feeds are imported")
;feedsdata = {} ; Global
err_code = ?LoadPrefs(feedsdata)
p_Replay(err_code, "Settings loaded")
EndFunction
Function p_SaveSettings()
p_SaveFeeds()
Local err_code = ?SavePrefs(feedsdata)
p_Replay(err_code, "State saved")
EndFunction
Function p_Lock()
mui.Set("fetchbtn", "Disabled", True)
mui.Set("fetchallbtn", "Disabled", True)
mui.Set("stopbtn", "Disabled", False)
PleaseStop = False
EndFunction
Function p_Unlock()
PleaseStop = True
mui.Set("stopbtn", "Disabled", True)
mui.Set("fetchbtn", "Disabled", False)
mui.Set("fetchallbtn", "Disabled", False)
EndFunction
Function p_StartLurk()
mui.Set("herewegobtn", "Disabled", True)
mui.Set("stoplurkbtn", "Disabled", False)
lurk.PleaseStop = False
lurk:Explore(mui.Get("websource", "Contents"))
mui.Set("stoplurkbtn", "Disabled", True)
mui.Set("herewegobtn", "Disabled", False)
EndFunction
mui.CreateGUI(ReadString(1))
InstallEventHandler({MUIRoyale = p_MUIEvent})
p_StartUpLoading()
Repeat
WaitEvent
Forever