diff options
Diffstat (limited to 'mail/freepops/patches/patch-ah')
-rw-r--r-- | mail/freepops/patches/patch-ah | 1043 |
1 files changed, 0 insertions, 1043 deletions
diff --git a/mail/freepops/patches/patch-ah b/mail/freepops/patches/patch-ah deleted file mode 100644 index b1bde48dcd3..00000000000 --- a/mail/freepops/patches/patch-ah +++ /dev/null @@ -1,1043 +0,0 @@ -$NetBSD: patch-ah,v 1.1 2008/10/23 04:40:55 schmonz Exp $ - ---- src/lua/hotmail.lua.orig 2008-05-27 10:23:22.000000000 -0400 -+++ src/lua/hotmail.lua -@@ -3,13 +3,11 @@ - -- - -- Released under the GNU/GPL license - -- Written by Russell Schwager <russell822@yahoo.com> ---- Patched by cdmackie (2007-09-11). ---- Fixed: lite login, live delete, corrupt messages, stuck at 1st message, classic delete more than 1 message - -- ************************************************************************** -- - - -- Globals - -- --PLUGIN_VERSION = "0.1.90" -+PLUGIN_VERSION = "0.1.92" - PLUGIN_NAME = "hotmail.com" - PLUGIN_REQUIRE_VERSION = "0.2.0" - PLUGIN_LICENSE = "GNU/GPL" -@@ -21,7 +19,8 @@ PLUGIN_DOMAINS = { "@hotmail.com","@msn. - "@charter.com", "@compaq.net","@passport.com", - "@hotmail.de", "@hotmail.it", "@hotmail.co.uk", - "@hotmail.co.jp", "@hotmail.fr", "@messengeruser.com", -- "@hotmail.com.ar", "@hotmail.co.th", "@hotmail.com.tr" -+ "@hotmail.com.ar", "@hotmail.co.th", "@hotmail.com.tr", -+ "@milanosemplice.it" - } - PLUGIN_PARAMETERS = { - {name="folder", description={ -@@ -106,9 +105,9 @@ local globals = { - -- - strRetLoginBadLogin = "(memberservices)", - strRetLoginSessionExpired = "(Sign in)", -- strRetLoginSessionExpiredLiveLight = '(</li></ul><a class="ManageLink" href="ManageFoldersLight%.aspx)', -+ strRetLoginSessionExpiredLiveLight = '(href="ManageFoldersLight%.aspx)', - strRetLoginSessionErrorLive = '(HM%.FppError)', -- strRetLoginSessionExpiredLive = '(new HM%.FppReturnPackage%(0,new HM', -+ strRetLoginSessionExpiredLive = '(new HM%.FppReturnPackage%(0,new HM)', - strRetStatBusy = "(form name=.hotmail.)", - - -- Regular expression to extract the mail server -@@ -147,6 +146,8 @@ local globals = { - strRegExpCrumb = '&a=([^"&]*)[&"]', - strRegExpCrumbLive = '"sessionidhash" : "([^"]+)"', - strRegExpUser = '"authuser" : "([^"]+)"', -+ strRegExpCrumbLiveLight = 'SessionId:"([^"]+)"', -+ strRegExpUserLiveLight = 'AuthUser:"([^"]+)"', - - -- MSN Inbox Folder Id - -- -@@ -167,7 +168,7 @@ local globals = { - strFolderPattern = '<a href="[^"]+curmbox=([^&]+)&[^"]+" >', - strFolderLivePattern = '%("([^"]+)","', - strFolderLiveInboxPattern = 'sysfldrinbox".-"([^"]+)"', -- strFolderLiveLightInboxPattern = 'href="InboxLight%.aspx%?(FolderID=[^&]+[^"]+)"[^>]+><img src=".-i_inbox.gif"', -+ strFolderLiveLightInboxPattern = 'fst="NONE".-href="InboxLight%.aspx%?(FolderID=[^&]+[^"]+)"[^>]+>', - strFolderLiveLightFolderIdPattern = 'FolderID=([^&]+)&[.]*', - strFolderLiveLightNPattern = '&n=([^&]+)[.]*', - -@@ -175,7 +176,7 @@ local globals = { - strFolderLiveLightTrash2Pattern = 'href="InboxLight%.aspx%?FolderID=([^&]+)&[^"]+"[^>]+><img src="[^"]+" class="i_trash"', - strFolderLiveLightJunkPattern = 'i_junkfolder%.gif" border="0" alt=""/></td>.-<td class="dManageFoldersFolderNameCol"><a href="InboxLight%.aspx%?FolderID=([^&]+)&', - strFolderLiveLightJunk2Pattern = 'href="InboxLight%.aspx%?FolderID=([^&]+)&[^"]+"[^>]+><img src="[^"]+" class="i_junkfolder"', -- strFolderLiveLightPattern = 'href="InboxLight%.aspx%?FolderID=([^&]+&n=[^"]+)" title="', -+ strFolderLiveLightPattern = 'href="InboxLight%.aspx%?(FolderID=[^&]+[^"]+)" title="', - strFolderLiveLightManageFoldersPattern = 'href="ManageFoldersLight%.aspx%?n=([^"]+)"', - - -- Pattern to determine if we have no messages -@@ -186,19 +187,22 @@ local globals = { - -- - strMsgListCntPattern = "<td width=100. align=center>([^<]+)</td><td align=right nowrap>", - strMsgListCntPattern2 = "([%d]+) [MmNnBbVv][eai]", -- strMsgListLiveLightCntPattern = '<div class=".-ItemListHeaderMsgInfo".->.-(%d+).-</div>', -- -+ --strMsgListLiveLightCntPattern = '<div class=".-ItemListHeaderMsgInfo".->.-(%d+).-</div>', -+ strMsgListLiveLightCntPattern = '>(%d+) %a+</div><div class="PageNavigation FloatRight"', -+ - -- Used by Stat to pull out the message ID and the size - -- - strMsgLineLitPattern = ".*<tr>.*<td>[.*]{img}.*</td>.*<td>.*<img>.*</td>.*<td>[.*]{img}.*</td>.*<td>.*<input>.*</td>.*<td>.*</td>.*<td>.*<a>.*</a>.*</td>.*<td>.*</td>.*<td>.*</td>.*<td>.*</td>.*</tr>", - strMsgLineAbsPattern = "O<O>O<O>[O]{O}O<O>O<O>O<O>O<O>O<O>[O]{O}O<O>O<O>O<X>O<O>O<O>O<O>O<O>O<O>O<O>O<O>O<O>O<O>O<O>O<O>O<O>X<O>O<O>", - -- - -- Pattern used by Stat to get the next page in the list of messages - -- - strMsgListNextPagePattern = '(nextpg%.gif" border=0></a>)', - strMsgListNextPagePatLiveLight = '<a href="([^"]+)"[^>]*><img src="[^_]*_nextpage.gif"', - strMsgListNextPagePatLiveLight2 = '<a href="([^"]+)"[^>]*><img src="[^"]+" class="i_nextpage"', -+ strMsgListNextPagePatLiveLight3 = 'pnCur=\\?"([^\\"]+)\\?" pnAm=\\?"([^\\"]+)\\?" pnAd=\\?"([^\\"]+)\\?" pnDir=\\?"NextPage\\?" pnMid=\\?"([^\\"]+)\\?" [^>]*>.-<[^>]+>.-<img [^_]*_nextpage\\?"', -+ -+ strMsgListNextPagePatLiveLight4 = '<li id="nextPageLink" pnCur="([^"]+)" pnAm="([^"]+)" pnAd="([^"]+)" pnDir="NextPage" pnMid="([^"]+)" pnSkip="0">', - - -- Pattern used to detect a bad STAT page. - -- -@@ -209,7 +213,13 @@ local globals = { - strMsgLivePatternOld = ',"([^"]+)","[^"]+","[^"]+",[^,]+,[^,]+,[^,]+,[^,]+,"([^"]+)"', - strMsgLivePattern1 = 'class=.-SizeCell.->([^<]+)</div>', - strMsgLivePattern2 = 'new HM%.__[^%(]+%("([^"]+)",[tf][^,"]+,"[^"]+",[^,]+,[^,]+', -- strMsgLiveLightPattern = 'ReadMessageId=([^&]+)&[^>]+>.-</a></td>.-<td [^>]+>.-</td>.-<td [^>]+>([^<]+)</td>', -+ strMsgLiveLightPatternOld = 'ReadMessageId=([^&]+)&[^>]+>.-</a></td>.-<td [^>]+>.-</td>.-<td [^>]+>([^<]+)</td>', -+ -- cdmackie 2008-07-02: new message patterns for live light -+ strMsgLiveLightPattern = '(<tr[^<>]-id=\\?"[^\\"]+\\?" msg=\\?"msg\\?"[^>]->)(.-)</tr>', -+ strMsgLiveLightPatternUidl = 'id=\\?"([^\\"]+)\\?"', -+ strMsgLiveLightPatternMad = 'mad=\\?"([^\\"]+)\\?"', -+ strMsgLiveLightPatternSize = 'class=\\?"TextAlignRight\\?"[^>]->(.-)</td>', -+ strMsgLiveLightPatternUnread = "(Unread)", - - -- The amount of time that the session should time out at. - -- This is expressed in seconds -@@ -233,14 +243,24 @@ local globals = { - strCmdMsgListPostLiveOld = "cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=GetFolderData&d=%s,Date,%s,false,0,%s,0,,&MailToken=", - strCmdMsgListPostLive = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=GetFolderData&d=%s,Date,%s,false,0,%s,0,"","",true,false&v=1&mt=%s', - -+ -- cdmackie 2008-07-02: new calls for STAT for live light -+ strCmdMsgListLive3 = "mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.GetInboxData&ptid=0&a=%s&au=%s", -+ strCmdMsgListPostLive3 = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=GetInboxData&d=true,true,{%%22%s%%22,25,NextPage,0,Date,false,%%22%s%%22,%%22%s%%22,%s,%s,false,%%22%%22,false,%s},false,null&v=1&mt=%s', -+ strCmdMsgListPostLive4 = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=GetInboxData&d=true,true,{%%22%s%%22,LastPage,0,Date,false,%%22%s%%22,%%22%s%%22,%s,%s,false,%%22%%22,%s,-1,Bottom},false,null&v=1&mt=%s', -+ - strCmdDelete = "http://%s/cgi-bin/HoTMaiL", - strCmdDeletePost = "curmbox=%s&_HMaction=delete&wo=&SMMF=0", -- &<MSGID>=on - strCmdDeleteLive = "http://%s/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.MoveMessages&ptid=0&a=%s&au=%s", - strCmdDeletePostLiveOld = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MoveMessages&d="%s","%s",[%s],[{"%%5C%%7C%%5C%%7C%%5C%%7C0%%5C%%7C%%5C%%7C%%5C%%7C00000000-0000-0000-0000-000000000001%%5C%%7C632901424233870000",{2,"00000000-0000-0000-0000-000000000000",0}}],null,null,0,false,Date&v=1', - -- strCmdDeletePostLive = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MoveMessages&d="%s","%s",[%s],[{"%%5C%%7C%%5C%%7C%%5C%%7C0%%5C%%7C%%5C%%7C%%5C%%7C%%5C%%7C00000000-0000-0000-0000-000000000001%%5C%%7C632750213035330000",null}],null,null,0,false,Date,false,true&v=1&mt=%s', - strCmdDeletePostLive = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MoveMessages&d="%s","%s",[%s],[{"0%%5C%%7C0%%5C%%7C8C9BDFF65883200%%5C%%7C00000000-0000-0000-0000-000000000001",null}],null,null,0,false,Date,false,true&v=1&mt=%s', -- strCmdDeleteLiveLight = "http://%s/mail/InboxLight.aspx?FolderID=%s&", -- strCmdDeletePostLiveLight = "__VIEWSTATE=&mt=%s&MoveMessageSelector=%s&ToolbarActionItem=MoveMessageSelector&", -- SelectedMessages=%s", -+ -+ --strCmdDeleteLiveLight = "http://%s/mail/InboxLight.aspx?FolderID=%s&", -+ --strCmdDeletePostLiveLight = "__VIEWSTATE=&mt=%s&MoveMessageSelector=%s&ToolbarActionItem=MoveMessageSelector&", -- SelectedMessages=%s", -+ strCmdDeleteLiveLight = "http://%s/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.MoveMessagesToFolder&ptid=0&a=%s&au=%s", -+ strCmdDeletePostLiveLight = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MoveMessagesToFolder&d="%s","%s",[%s],[%s],{"%s",25,FirstPage,0,Date,false,"00000000-0000-0000-0000-000000000000","",1,2,false,"",false,0},null&v=1&mt=%s', -+ strCmdDeletePostLiveLight2 = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MoveMessagesToFolder&d="%s","%s",[%s],[%s],{"%s",FirstPage,0,Date,false,"00000000-0000-0000-0000-000000000000","",1,2,false,"",26,0,Bottom}&v=1&mt=%s', -+ - strCmdMsgView = "http://%s/cgi-bin/getmsg?msg=%s&imgsafe=y&curmbox=%s&a=%s", - strCmdMsgViewRaw = "&raw=0", - strCmdMsgViewLive = "http://%s/mail/GetMessageSource.aspx?msgid=%s&gs=true", -@@ -253,11 +273,13 @@ local globals = { - strCmdMsgUnreadLivePost = "cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MarkMessages&d=false,[%s]", - strCmdEmptyTrashLive = "http://%s/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.EmptyFolder&ptid=0&a=&au=%s", - strCmdEmptyTrashLivePost = "cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=EmptyFolder&d=%s,1&v=1&mt=%s", -- strCmdEmptyTrashLiveLight = "http://%s/mail/InboxLight.aspx?EmptyFolder=True&FolderID=%s&", -- strCmdEmptyTrashLiveLightPost = "__VIEWSTATE=&mt=%s&query=&MoveMessageSelector=&ToolbarActionItem=&InfoPaneActionItem=EmptyFolderConfirmYes", -+ strCmdEmptyTrashLiveLight = "http://%s/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.ClearFolder&ptid=0&a=%s&au=%s", -+ strCmdEmptyTrashLiveLightPost = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=ClearFolder&d="%s",{"%s",25,FirstPage,0,Date,false,"00000000-0000-0000-0000-000000000000","",1,2,false,"",false,0}&v=1&mt=%s', - strCmdMsgReadLive = "http://%s/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.MarkMessages&ptid=0&a=&au=%s", - strCmdMsgReadLivePost = "cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MarkMessages&d=true,[%s]&v=1&mt=%s", -- strCmdMsgReadLiveLight = "http://%s/mail/ReadMessageLight.aspx?AllowUnsafe=True&Aux=&FolderID=%s&InboxSortAscending=False&InboxSortBy=Date&ReadMessageId=%s", -+ --strCmdMsgReadLiveLight = "http://%s/mail/ReadMessageLight.aspx?AllowUnsafe=True&Aux=&FolderID=%s&InboxSortAscending=False&InboxSortBy=Date&ReadMessageId=%s", -+ strCmdMsgReadLiveLight = "http://%s/mail/mail.fpp?cnmn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox.MarkMessagesReadState&ptid=0&a=%s&au=%s", -+ strCmdMsgReadLiveLightPost = 'cn=Microsoft.Msn.Hotmail.Ui.Fpp.MailBox&mn=MarkMessagesReadState&d=true,["%s"],{"%s",25,FirstPage,0,Date,false,"00000000-0000-0000-0000-000000000000","",1,2,false,"",false,0}&v=1&mt=%s', - } - - -- ************************************************************************** -- -@@ -288,6 +310,8 @@ internalState = { - strUserId = "", - strMT = "", - bKeepMsgStatus = false, -+ msgIds = {}, -+ unreadStatus = {}, - } - - -- ************************************************************************** -- -@@ -354,6 +378,13 @@ end - - function getPage(browser, url, post, name) - local try = 0 -+ -+ if post ~= nil then -+ log.raw("LOADING: " .. url .. "\nPOST: " .. post .. "\n") -+ else -+ log.raw("LOADING: " .. url .. "\n") -+ end -+ - while (try < 3) do - try = try + 1 - local body, err = fetchPage(browser, url, post, name) -@@ -363,9 +394,11 @@ function getPage(browser, url, post, nam - log.error_print("Tried to load: " .. url .. " and got error: " .. err) - return nil, err - else -+ log.raw(body .. "\n\n") -+ - if (string.find(body, "We are experiencing higher than normal volume") == nil and -- string.find(body, "<[Hh][Tt][Mm][Ll]") ~= nil and -- string.find(body, "MSN Hotmail %- ERROR") == nil) then -+ (string.find(body, "<[Hh][Tt][Mm][Ll]") ~= nil or string.find(body, "new HM.FppReturnPackage") ~= nil) and -+ string.find(body, "MSN Hotmail %- ERROR") == nil ) then - return body, err - end - -- This is a little bizarre -- It seems the condition should not be here. -@@ -383,11 +416,23 @@ end - - function fetchPage(browser, url, post, name) - log.dbg("Fetching Page: " .. name .. " - " .. url) -+ local body, err - if (post == nil) then -- return browser:get_uri(url) -+ body, err = browser:get_uri(url) - else -- return browser:post_uri(url, post) -+ body, err = browser:post_uri(url, post) - end -+ -+ local lastpage = browser:whathaveweread() -+ if (string.match(lastpage, "browsersupport")) then -+ if (post == nil) then -+ body, err = browser:get_uri(url) -+ else -+ body, err = browser:post_uri(url, post) -+ end -+ end -+ -+ return body, err - end - - -- Issue the command to login to Hotmail -@@ -403,8 +448,8 @@ function loginHotmail() - - -- Create a browser to do the dirty work - -- -- --internalState.browser = browser.new("Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; YPC 3.0.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727") -- internalState.browser = browser.new("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12") -+ internalState.browser = browser.new("Mozilla/5.0 (Windows; U; Windows NT 5.1; en) AppleWebKit/522.11.3 (KHTML, like Gecko) Version/3.0 Safari/522.11.3") -+ --internalState.browser = browser.new("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.12) Gecko/20080207 Ubuntu/7.10 (gutsy) Firefox/2.0.0.12") - - -- Define some local variables - -- -@@ -520,6 +565,21 @@ function loginHotmail() - body, err = getPage(browser, "http://www.hotmail.com", nil, "hotmail homepage") - end - -+ -- Let's look for a message at login -+ -- -+ local hasMsgAtLogin = false -+ url = string.match(body, '<form name="MessageAtLoginForm" method="post" action="([^"]+)"') -+ if (url ~= nil) then -+ hasMsgAtLogin = true -+ url = string.gsub(url, "&", "&") -+ local post = "" -+ for name, value in string.gfind(body, '<input type="hidden" name="([^"]+)".-value="([^"]+)"') do -+ post = post .. name .. "=" .. value .. "&" -+ end -+ url = "http://" .. browser:wherearewe() .. "/mail/" .. url -+ body, err = getPage(browser, url, post, "Message At Login Form") -+ end -+ - -- Check to see if we are using the new interface and are redirecting. - -- - local folderBody = body -@@ -560,23 +620,24 @@ function loginHotmail() - - -- Paco - body = cleanupLoginBody(body) -- -- url = string.match(body, globals.strLoginDoneReloadToHMHome1) -+ -+ url = string.match(body, globals.strLoginDoneReloadToHMHome1) - if url == nil then - url = string.match(body, globals.strLoginDoneReloadToHMHome2) - if url == nil then - -- Change suggested by 930 - local authimgurl = string.match(body, globals.strLoginDoneReloadToHMHome4) -- -- Paco -- -- -- if authimgurl == nil then -- authimgurl = string.match(body, globals.strLoginDoneReloadToHMHome5) -- end -- log.raw("Image url: " .. authimgurl) -+ -+ -- Paco -+ -- -+ if authimgurl == nil then -+ authimgurl = string.match(body, globals.strLoginDoneReloadToHMHome5) -+ end -+ log.raw("Image url: " .. authimgurl) - -- if authimgurl ~= nil then -- getPage(browser, authimgurl, nil, "Authentication Image Url - NonLive") -- end -+ if authimgurl ~= nil then -+ getPage(browser, authimgurl, nil, "Authentication Image Url - NonLive") -+ end - url = string.match(body, globals.strLoginDoneReloadToHMHome3) - if url == nil then - log.error_print(globals.strLoginFailed) -@@ -593,7 +654,7 @@ function loginHotmail() - log.error_print(globals.strLoginFailed) - log.raw("Login failed: Sent login info to: " .. (url or "none") .. " and got an error:\n" .. err); - return POPSERVER_ERR_NETWORK -- end -+ end - end - - -- Extract the crumb - This is needed for deletion of items -@@ -628,6 +689,10 @@ function loginHotmail() - -- - log.dbg("Hotmail Authuser value: " .. user .. "\n") - end -+ else -+ -- Force this to be the empty string for live light -- older versions. Eventually we could probably remove this. -+ -- -+ internalState.strCrumb = '' - end - - -- Get the MT cookie value -@@ -648,9 +713,8 @@ function loginHotmail() - - -- Find the image server - -- -- if (internalState.bLiveGUI == true) then -- str = string.match(body, globals.strImgServerLivePattern) -- else -+ str = string.match(body, globals.strImgServerLivePattern) -+ if (str == nil) then - str = string.match(body, globals.strImgServerPattern) - end - -@@ -730,16 +794,17 @@ function loginHotmail() - - body, err = getPage(browser, url, nil, "LiveLight - Manage Folders") - -- -- cdmackie: we then extract the querystring and apend the InboxId with the N value -- local inboxQueryString = string.match(body, globals.strFolderLiveLightInboxPattern) -- local inboxId = string.match(inboxQueryString, globals.strFolderLiveLightFolderIdPattern) -- local inboxN = string.match(inboxQueryString, globals.strFolderLiveLightNPattern) -- inboxId = inboxId .. "&n=" .. inboxN -- -+ -- cdmackie 2008-07-06: fix patter to get folder IDs - if (internalState.strMBoxName == "Inbox") then -- str = inboxId -+ str = string.match(body, globals.strFolderLiveLightInboxPattern) -+ local id = string.match(str, globals.strFolderLiveLightFolderIdPattern) -+ local n = string.match(str, globals.strFolderLiveLightNPattern) -+ str = id .. "&n=" .. n - else - str = string.match(body, globals.strFolderLiveLightPattern .. internalState.strMBoxName) -+ local id = string.match(str, globals.strFolderLiveLightFolderIdPattern) -+ local n = string.match(str, globals.strFolderLiveLightNPattern) -+ str = id .. "&n=" .. n - end - - if (str == nil) then -@@ -752,33 +817,49 @@ function loginHotmail() - - -- Get the trash folder id and the junk folder id - -- -- str = string.match(body, globals.strFolderLiveLightTrashPattern) -- if str ~= nil then -- internalState.strTrashId = str -- log.dbg("Hotmail - trash folder id: " .. str) -- else -- str = string.match(body, globals.strFolderLiveLightTrash2Pattern) -+ local idx = 0 -+ for folderId in string.gfind(body, "javascript:confirmDeleteFolder%('([^']+)'") do -+ if idx == 0 then -+ internalState.strJunkId = folderId -+ log.dbg("Hotmail - junk folder id: " .. folderId) -+ elseif idx == 1 then -+ internalState.strTrashId = folderId -+ log.dbg("Hotmail - trash folder id: " .. folderId) -+ end -+ idx = idx + 1 -+ end -+ -+ if (internalState.strTrashId == nil) then -+ str = string.match(body, globals.strFolderLiveLightTrashPattern) - if str ~= nil then - internalState.strTrashId = str - log.dbg("Hotmail - trash folder id: " .. str) - else -- log.error_print("Unable to detect the folder id for the trash folder. Deletion may fail.") -- end -- end -+ str = string.match(body, globals.strFolderLiveLightTrash2Pattern) -+ if str ~= nil then -+ internalState.strTrashId = str -+ log.dbg("Hotmail - trash folder id: " .. str) -+ else -+ log.error_print("Unable to detect the folder id for the trash folder. Deletion may fail.") -+ end -+ end -+ end - -- str = string.match(body, globals.strFolderLiveLightJunkPattern) -- if str ~= nil then -- internalState.strJunkId = str -- log.dbg("Hotmail - junk folder id: " .. str) -- else -- str = string.match(body, globals.strFolderLiveLightJunk2Pattern) -+ if (internalState.strJunkId == nil) then -+ str = string.match(body, globals.strFolderLiveLightJunkPattern) - if str ~= nil then - internalState.strJunkId = str - log.dbg("Hotmail - junk folder id: " .. str) - else -- log.error_print("Unable to detect the folder id for the junk folder. Deletion may fail.") -- end -- end -+ str = string.match(body, globals.strFolderLiveLightJunk2Pattern) -+ if str ~= nil then -+ internalState.strJunkId = str -+ log.dbg("Hotmail - junk folder id: " .. str) -+ else -+ log.error_print("Unable to detect the folder id for the junk folder. Deletion may fail.") -+ end -+ end -+ end - end - - -- Note that we have logged in successfully -@@ -797,7 +878,7 @@ function loginHotmail() - end - - function cleanupLoginBody(body) -- log.raw("Cleaning up login body: " .. body) -+ --log.raw("Cleaning up login body: " .. body) - body = string.gsub(body, ":", ":") - body = string.gsub(body, "=", "=") - body = string.gsub(body, "'", "'") -@@ -813,7 +894,7 @@ function cleanupLoginBody(body) - body = string.gsub(body, "\\x3f", "?") - body = string.gsub(body, "\\x3d", "=") - body = string.gsub(body, "\\x26", "&") -- log.raw("Body cleaned: " .. body) -+ --log.raw("Body cleaned: " .. body) - - return body - end -@@ -841,7 +922,6 @@ function downloadMsg(pstate, msg, nLines - -- - local browser = internalState.browser - local uidl = get_mailmessage_uidl(pstate, msg) -- - local url = string.format(globals.strCmdMsgView, internalState.strMailServer, - uidl, internalState.strMBox, internalState.strCrumb); - local markReadUrl = url -@@ -958,8 +1038,13 @@ function downloadMsg(pstate, msg, nLines - browser:post_uri(url, post) - elseif internalState.bMarkMsgAsUnread == false and internalState.bLiveGUI and internalState.bLiveLightGUI then - log.raw("Message: " .. cbInfo.cb_uidl .. ", Marking message as read.") -- url = string.format(globals.strCmdMsgReadLiveLight, internalState.strMailServer, internalState.strMBox, uidl) -- browser:get_head(url) -+ -- cdmackie: 2008-07-05 use new MarkMessagesReadState command -+ --url = string.format(globals.strCmdMsgReadLiveLight, internalState.strMailServer, internalState.strMBox, uidl) -+ url = string.format(globals.strCmdMsgReadLiveLight, internalState.strMailServer, internalState.strCrumb, internalState.strUserId) -+ local inboxid = string.gsub(internalState.strMBox, "&n=.*", "") -+ local post = string.format(globals.strCmdMsgReadLiveLightPost, uidl, inboxid, internalState.strMT) -+ post = string.gsub(post, '"', "%%22") -+ browser:post_uri(url, post) - elseif internalState.bMarkMsgAsUnread == true and internalState.bLiveGUI == true then - log.raw("Message: " .. cbInfo.cb_uidl .. ", Marking message as unread.") - url = string.format(globals.strCmdMsgUnreadLive, internalState.strMailServer, internalState.strCrumb, internalState.strUserId) -@@ -1059,50 +1144,57 @@ function cleanupHeaders(headers, cbInfo) - local bMissingID = false -- when no Message-ID -field seems to have been automatically generated ? - local bodyrest = "" - -- headers, bodyrest = string.match(headers, "^(.-)\r*\n%s*\r*\n(.*)$" ) -+ headers, bodyrest = string.match(headers, "^(.-\r\n.-)\r\n(.*)$" ) - - if (headers == nil) then - log.dbg("Hotmail: unable to parse out message headers. Extra headers will not be used.") - return origHeaders - end - -- headers = string.gsub(headers, "%s+$", "\n") -- headers = headers .. "\n"; -- headers = string.gsub(headers, "\n\n", "\n") -- headers = string.gsub(headers, "\r\n", "\n") -- headers = string.gsub(headers, "\n", "\r\n") -+ --headers = string.gsub(headers, "%s+$", "\n") -+ --headers = headers .. "\n"; -+ --headers = string.gsub(headers, "\n\n", "\n") -+ --headers = string.gsub(headers, "\r\n", "\n") -+ --headers = string.gsub(headers, "\n", "\r\n") - - -- - -- some checking... - -- -- if string.find(headers, "(To:)") == nil then -- bMissingTo = true -- end -- if string.find(headers, "(Message%-I[dD]:)") == nil then -- bMissingID = true -- end -+-- if string.find(headers, "(To:)") == nil then -+-- bMissingTo = true -+-- end -+-- if string.find(headers, "(Message%-I[dD]:)") == nil then -+-- bMissingID = true -+-- end - - -- Add some headers - -- -+ local newheaders = "" - if bMissingTo ~= false then -- headers = headers .. "To: " .. internalState.strUser .. "@" .. internalState.strDomain .. "\r\n" ; -+ newheaders = newheaders .. "To: " .. internalState.strUser .. "@" .. internalState.strDomain .. "\r\n" ; - end - - if bMissingID ~= false then - local msgid = cbInfo.cb_uidl .. "@" .. internalState.strMailServer -- well, if we do not have any better choice... -- headers = headers .. "Message-ID: <" .. msgid .. ">\r\n" -+ newheaders = newheaders .. "Message-ID: <" .. msgid .. ">\r\n" -+ end -+ -+ local readStatus = "read" -+ if (internalState.unreadStatus[cbInfo.cb_uidl]) then -+ readStatus = "unread" - end - -- headers = headers .. "X-FreePOPs-User: " .. internalState.strUser .. "@" .. internalState.strDomain .. "\r\n" -- headers = headers .. "X-FreePOPs-Domain: " .. internalState.strDomain .. "\r\n" -- headers = headers .. "X-FreePOPs-Folder: " .. internalState.strMBox .. "\r\n" -- headers = headers .. "X-FreePOPs-MailServer: " .. internalState.strMailServer .. "\r\n" -- headers = headers .. "X-FreePOPs-ImageServer: " .. internalState.strImgServer .. "\r\n" -- headers = headers .. "X-FreePOPs-MsgNumber: " .. "<" .. cbInfo.cb_uidl .. ">" .. "\r\n" -+ newheaders = newheaders .. "X-FreePOPs-User: " .. internalState.strUser .. "@" .. internalState.strDomain .. "\r\n" -+ newheaders = newheaders .. "X-FreePOPs-Domain: " .. internalState.strDomain .. "\r\n" -+ newheaders = newheaders .. "X-FreePOPs-Folder: " .. internalState.strMBox .. "\r\n" -+ newheaders = newheaders .. "X-FreePOPs-MailServer: " .. internalState.strMailServer .. "\r\n" -+ newheaders = newheaders .. "X-FreePOPs-ImageServer: " .. internalState.strImgServer .. "\r\n" -+ newheaders = newheaders .. "X-FreePOPs-MsgNumber: " .. "<" .. cbInfo.cb_uidl .. ">" .. "\r\n" -+ newheaders = newheaders .. "X-FREEPOPS-READ-STATUS: " .. readStatus .. "\r\n" - - -- make the final touch... - -- -- headers = headers .. "\r\n" .. bodyrest -+ headers = headers .. "\r\n" .. newheaders .. bodyrest - - return headers - end -@@ -1127,13 +1219,16 @@ function cleanupBody(body, cbInfo) - -- - body = string.gsub(body, "<pre>[%s]*", "") - body = string.gsub(body, "</pre>.-$", "\n") -+ -- cdmackie: sometimes we get only "</" -+ body = string.gsub(body, "</$", "\n") - - -- Clean up the end of line, and replace HTML tags - -- -+ body = string.gsub(body, " ", "\n") -- appears in some spam messages and destroys the headers - body = string.gsub(body, "	", "\t") - body = string.gsub(body, "	", "\t") - body = string.gsub(body, " ", "\n") -- body = string.gsub(body, " ", "\r") -+ body = string.gsub(body, " ", "") - body = string.gsub(body, "", "\27") - body = string.gsub(body, " ", " ") - body = string.gsub(body, "!", "!") -@@ -1198,9 +1293,17 @@ function cleanupBody(body, cbInfo) - body = string.gsub(body, "\r\n%.", "\r\n%.%.") - - -- Experimental -- For non-ascii users -- -- -- body = string.gsub(body, "&#(%d-);", function(c) return string.byte(c) end) -- -+ body = string.gsub(body, "&#(%d*);", -+ function(c) -+ c = tonumber(c) -+ if (c > 255) then -+ return "&#" .. c .. ";" -+ else -+ return string.char(c) -+ end -+ end -+ ) -+ - -- We've now at least seen one block, attempt to clean up the headers - -- - if (cbInfo.bFirstBlock == true) then -@@ -1397,6 +1500,7 @@ function quit_update(pstate) - local post = postBase - local uidls = "" - local uidlsLight = "" -+ local madsLight = "" - - -- Cycle through the messages and see if we need to delete any of them - -- -@@ -1420,8 +1524,15 @@ function quit_update(pstate) - post = postBase - end - elseif internalState.bLiveGUI == true and internalState.bLiveLightGUI and get_mailmessage_flag(pstate, i, MAILMESSAGE_DELETE) then -- -- cdmackie: uidlsLight should be appended for multiple messages -- uidlsLight = uidlsLight .. "SelectedMessages=" .. get_mailmessage_uidl(pstate, i) .. "&" -+ -- cdmackie: 2008-07-09 string contains UIDLS and "mad" attribute from inbox -+ local uidl, mad = string.match(internalState.msgIds[i], "(.-)&(.*)") -+ if i > 1 then -+ uidlsLight = uidlsLight .. ',"' .. uidl .. '"' -+ madsLight = madsLight .. ',{"' .. mad .. '",null}' -+ else -+ uidlsLight = '"' .. uidl .. '"' -+ madsLight = '{"' .. mad .. '",null}' -+ end - dcnt = dcnt + 1 - elseif internalState.bLiveGUI == true and get_mailmessage_flag(pstate, i, MAILMESSAGE_DELETE) then - if i > 1 then -@@ -1442,12 +1553,29 @@ function quit_update(pstate) - log.error_print("Unable to delete messages.\n") - end - elseif dcnt > 0 and internalState.bLiveGUI and internalState.bLiveLightGUI == true then -- cmdUrl = string.format(globals.strCmdDeleteLiveLight, internalState.strMailServer, internalState.strMBox) -- post = string.format(globals.strCmdDeletePostLiveLight, internalState.strMT, -- internalState.strTrashId) .. uidlsLight -+ cmdUrl = string.format(globals.strCmdDeleteLiveLight, internalState.strMailServer, internalState.strCrumb, internalState.strUserId) -+ -+ -- This is the older interface's way to delete it. -+ -- -+ local inboxid = string.gsub(internalState.strMBox, "&n=.*", "") -+ post = string.format(globals.strCmdDeletePostLiveLight, -+ inboxid, internalState.strTrashId, -+ uidlsLight, madsLight, -+ inboxid, internalState.strMT) -+ post = string.gsub(post, '"', "%%22") - log.dbg("Sending Trash url: " .. cmdUrl .. " - " .. post) - local body, err = getPage(browser, cmdUrl, post, "Delete Messages - LiveLight") -- elseif dcnt > 0 and internalState.bLiveGUI then -+ -+ -- This is less than ideal and will need to be fixed soon. This is the newer way to delete. -+ -- -+ post = string.format(globals.strCmdDeletePostLiveLight2, -+ inboxid, internalState.strTrashId, -+ uidlsLight, madsLight, -+ inboxid, internalState.strMT) -+ post = string.gsub(post, '"', "%%22") -+ local body, err = getPage(browser, cmdUrl, post, "Delete Messages - LiveLight - Newer version") -+ -+ elseif dcnt > 0 and internalState.bLiveGUI then - cmdUrl = string.format(globals.strCmdDeleteLive, internalState.strMailServer, internalState.strCrumb, internalState.strUserId) - uidls = string.gsub(uidls, ",", '","') - uidls = '"' .. uidls .. '"' -@@ -1476,9 +1604,11 @@ function quit_update(pstate) - log.error_print("Cannot empty trash - crumb not found\n") - end - elseif internalState.bEmptyTrash and internalState.bLiveGUI and internalState.bLiveLightGUI == true then -- cmdUrl = string.format(globals.strCmdEmptyTrashLiveLight, internalState.strMailServer, internalState.strTrashId) -- local post = string.format(globals.strCmdEmptyTrashLiveLightPost, internalState.strMT) -- log.dbg("Sending Empty Trash URL: " .. cmdUrl .."\n") -+ cmdUrl = string.format(globals.strCmdEmptyTrashLiveLight, internalState.strMailServer, internalState.strCrumb, internalState.strUserId) -+ local inboxid = string.gsub(internalState.strMBox, "&n=.*", "") -+ local post = string.format(globals.strCmdEmptyTrashLiveLightPost,internalState.strTrashId, inboxid, internalState.strMT) -+ post = string.gsub(post, '"', "%%22") -+ log.dbg("Sending Empty Trash URL: " .. cmdUrl ..", POST: " .. post .. "\n") - local body, err = getPage(browser, cmdUrl, post, "LiveLight - Empty Trash") - if not body or err then - log.error_print("Error when trying to empty the trash with url: ".. cmdUrl .."\n") -@@ -1496,9 +1626,11 @@ function quit_update(pstate) - -- Empty the Junk Folder - -- - if internalState.bEmptyJunk and internalState.bLiveGUI and internalState.bLiveLightGUI == true then -- cmdUrl = string.format(globals.strCmdEmptyTrashLiveLight, internalState.strMailServer, internalState.strJunkId) -- local post = string.format(globals.strCmdEmptyTrashLiveLightPost, internalState.strMT) -- log.dbg("Sending Empty Junk URL: " .. cmdUrl .."\n") -+ cmdUrl = string.format(globals.strCmdEmptyTrashLiveLight, internalState.strMailServer, internalState.strCrumb, internalState.strUserId) -+ local inboxid = string.gsub(internalState.strMBox, "&n=.*", "") -+ local post = string.format(globals.strCmdEmptyTrashLiveLightPost,internalState.strJunkId, inboxid, internalState.strMT) -+ post = string.gsub(post, '"', "%%22") -+ log.dbg("Sending Empty Junk URL: " .. cmdUrl ..", POST: " .. post .. "\n") - local body, err = getPage(browser, cmdUrl, post, "LiveLight - Empty Junk") - if not body or err then - log.error_print("Error when trying to empty the junk folder with url: ".. cmdUrl .."\n") -@@ -1592,7 +1724,7 @@ function LiveStat(pstate) - post = string.format(globals.strCmdMsgListPostLiveOld, internalState.strMBox, nMaxMsgs, nMaxMsgs) - body, err = browser:post_uri(cmdUrl, post) - end -- log.raw(body) -+ --log.raw(body) - - -- Let's make sure the session is still valid - -- -@@ -1608,7 +1740,7 @@ function LiveStat(pstate) - else - strLog = strLog .. ": " .. body - end -- log.raw(strLog) -+ --log.raw(strLog) - - -- Try Logging back in - -- -@@ -1632,10 +1764,7 @@ function LiveStat(pstate) - for uidl, size in string.gfind(body, globals.strMsgLivePatternOld) do - nMsgs = nMsgs + 1 - if (nMsgs <= nMaxMsgs) then -- log.dbg("Processed STAT - Msg: " .. nMsgs .. ", UIDL: " .. uidl .. ", Size: " .. size) -- set_popstate_nummesg(pstate, nMsgs) -- set_mailmessage_size(pstate, nMsgs, size) -- set_mailmessage_uidl(pstate, nMsgs, uidl) -+ processMessage(uidl, sizes[i], nMsgs, pstate) - end - end - -@@ -1666,11 +1795,7 @@ function LiveStat(pstate) - for uidl in string.gfind(body, globals.strMsgLivePattern2) do - nMsgs = nMsgs + 1 - if (nMsgs <= nMaxMsgs) then -- log.dbg("Processed STAT - Msg: " .. nMsgs .. ", UIDL: " .. uidl .. ", Size: " .. sizes[i]) -- -- set_popstate_nummesg(pstate, nMsgs) -- set_mailmessage_size(pstate, nMsgs, sizes[i]) -- set_mailmessage_uidl(pstate, nMsgs, uidl) -+ processMessage(uidl, sizes[i], nMsgs, pstate) - i = i + 1 - end - end -@@ -1706,6 +1831,7 @@ function stat(pstate) - local nTotMsgs = 0 - local lastNMsgs = 0 - local cmdUrl = "" -+ local cmdUrlPost = nil - if (internalState.bLiveLightGUI) then - cmdUrl = string.format(globals.strCmdMsgListLiveLight, internalState.strMailServer, - internalState.strMBox); -@@ -1715,6 +1841,7 @@ function stat(pstate) - end - local baseUrl = cmdUrl - local nextPageUrl = nil -+ local nextPageUrlPost = nil - - -- Keep a list of IDs that we've seen. With yahoo, their message list can - -- show messages that we've already seen. This, although a bit hacky, will -@@ -1722,6 +1849,9 @@ function stat(pstate) - -- really sucks! - -- - local knownIDs = {} -+ -+ -- keep msgIds for Hotmail to include the n value -+ internalState.msgIds = {} - - -- Debug Message - -- -@@ -1777,33 +1907,13 @@ function stat(pstate) - break - end - end -- -- -- Convert the size from it's string (4KB or 2MB) to bytes -- -- First figure out the unit (KB or just B) -- -- -- local kbUnit = string.match(size, "([Kk])") -- size = string.match(size, "([%d%.,]+)[KkMm]") -- if (size ~= nil) then -- size = string.gsub(size, ",", ".") -- end -- if (size ~= nil and tonumber(size) ~= nil) then -- if not kbUnit then -- size = math.max(tonumber(size), 0) * 1024 * 1024 -- else -- size = math.max(tonumber(size), 0) * 1024 -- end -- else -- size = 1024 -- end -+ size = parseSize(size) - - -- Save the information - -- - if bUnique == true and ((nMsgs < nTotMsgs and nTotMsgs ~= 0) or nTotMsgs == 0) then - nMsgs = nMsgs + 1 -- log.dbg("Processed STAT - Msg: " .. nMsgs .. ", UIDL: " .. uidl .. ", Size: " .. size) -- set_popstate_nummesg(pstate, nMsgs) -- set_mailmessage_size(pstate, nMsgs, size) -- set_mailmessage_uidl(pstate, nMsgs, uidl) -+ processMessage(uidl, size, nMsgs, pstate) - knownIDs[nMsgs] = uidl - end - end -@@ -1820,27 +1930,64 @@ function stat(pstate) - -- - local function funcProcessLiveLight(body) - lastNMsgs = nMsgs -- -+ - -- Figure out if there are more pages with messages - -- - nextPageUrl = string.match(body, globals.strMsgListNextPagePatLiveLight) -+ -- cdmackie 2008-07-02: qw now have to build post for subsequent page calls -+ nextPageUrlPost = nil -+ if nextPageUrl == nil then -+ local startpos, endpos, pcur, pnam, pnad, pnmid = string.find(body, globals.strMsgListNextPagePatLiveLight3) -+ local pattern4Use = false -+ if (startpos == nil) then -+ startpos, endpos, pcur, pnam, pnad, pnmid = string.find(body, globals.strMsgListNextPagePatLiveLight4) -+ pattern4Use = true -+ end -+ if startpos ~= nil then -+ nextPageUrl = string.format(globals.strCmdMsgListLive3, internalState.strCrumb, internalState.strUserId) -+ local inboxid = string.gsub(internalState.strMBox, "&n=.*", "") -+ pnad = cleanupLoginBody(pnad) -- replace : with colons -+ pnad = string.gsub(pnad, ":", "%%5C%%3A") -- replace colons with %5C%3A -+ if pattern4Use then -+ nextPageUrlPost = string.format(globals.strCmdMsgListPostLive4, inboxid, pnam, pnad, pcur, pnmid, nTotMsgs, internalState.strMT) -+ else -+ nextPageUrlPost = string.format(globals.strCmdMsgListPostLive3, inboxid, pnam, pnad, pcur, pnmid, nTotMsgs, internalState.strMT) -+ end -+ end -+ end - -- cdmackie: change in hotmail nextpage link (kept old one incase still used) - if nextPageUrl == nil then - nextPageUrl = string.match(body, globals.strMsgListNextPagePatLiveLight2) - end - if (nextPageUrl ~= nil) then -- log.dbg("Found another page of messages: " .. nextPageUrl) -+ if (nextPageUrlPost ~= nil) then -+ log.dbg("Found another page of messages: " .. nextPageUrl .. ", POST:" .. nextPageUrlPost) -+ else -+ log.dbg("Found another page of messages: " .. nextPageUrl) -+ end - end - - -- Tokenize out the message ID and size for each item in the list - -- -- for uidl, size in string.gfind(body, globals.strMsgLiveLightPattern) do -+ -- cdmackie 2008-07-02: new message patterns and different for first and ajax calls -+ for msgrow, msgcells in string.gfind(body, globals.strMsgLiveLightPattern) do -+ local mad = string.match(msgrow, globals.strMsgLiveLightPatternMad) -+ local uidl = string.match(msgrow, globals.strMsgLiveLightPatternUidl) -+ local fulluidl = uidl .. "&" .. mad -+ local size = string.match(msgcells, globals.strMsgLiveLightPatternSize) -+ if (size == nil) then -+ size = "1 KB" -- Some versions of hotmail don't display the size. -+ end - - if not uidl or not size then - log.say("Hotmail Module needs to fix it's individual message list pattern matching.\n") - return nil, "Unable to parse the size and uidl from the html" - end - -+ if (string.match(msgrow, globals.strMsgLiveLightPatternUnread)) then -+ internalState.unreadStatus[uidl] = true -+ end -+ - local bUnique = true - for j = 0, nMsgs do - if knownIDs[j + 1] == uidl then -@@ -1848,37 +1995,45 @@ function stat(pstate) - break - end - end -+ size = parseSize(size) - -- -- Convert the size from it's string (4KB or 2MB) to bytes -- -- First figure out the unit (KB or just B) -+ -- Save the information - -- -- local kbUnit = string.match(size, "([Kk])") -- size = string.match(size, "([%d%.,]+)[KkMm]") -- if (size ~= nil) then -- size = string.gsub(size, ",", ".") -- end -- if (size ~= nil and tonumber(size) ~= nil) then -- if not kbUnit then -- size = math.max(tonumber(size), 0) * 1024 * 1024 -- else -- size = math.max(tonumber(size), 0) * 1024 -- end -- else -- size = 1024 -+ if bUnique == true and ((nMsgs < nTotMsgs and nTotMsgs ~= 0) or nTotMsgs == 0) then -+ nMsgs = nMsgs + 1 -+ processMessage(uidl, size, nMsgs, pstate) -+ knownIDs[nMsgs] = uidl -+ internalState.msgIds[nMsgs] = fulluidl -+ end -+ end -+ -+ -- Some accounts haven't been upgraded to the newer version of the live light interface and thus, we need to make a second chec. -+ -- This is terrible and needs to be removed when it can be! -+ for uidl, size in string.gfind(body, globals.strMsgLiveLightPatternOld) do -+ if not uidl or not size then -+ log.say("Hotmail Module needs to fix it's individual message list pattern matching.\n") -+ return nil, "Unable to parse the size and uidl from the html" -+ end -+ -+ local bUnique = true -+ for j = 0, nMsgs do -+ if knownIDs[j + 1] == uidl then -+ bUnique = false -+ break -+ end - end -+ size = parseSize(size) - - -- Save the information - -- - if bUnique == true and ((nMsgs < nTotMsgs and nTotMsgs ~= 0) or nTotMsgs == 0) then - nMsgs = nMsgs + 1 -- log.dbg("Processed STAT - Msg: " .. nMsgs .. ", UIDL: " .. uidl .. ", Size: " .. size) -- set_popstate_nummesg(pstate, nMsgs) -- set_mailmessage_size(pstate, nMsgs, size) -- set_mailmessage_uidl(pstate, nMsgs, uidl) -+ processMessage(uidl, size, nMsgs, pstate) - knownIDs[nMsgs] = uidl -+ internalState.msgIds[nMsgs] = uidl - end -- end -- -+ end -+ - -- We are done with this page, increment the counter - -- - nPage = nPage + 1 -@@ -1890,16 +2045,24 @@ function stat(pstate) - -- change the command url - -- - local function funcCheckForMorePages(body) -- -- -+ -- Prevent an infinite loop -+ -- -+ if (lastNMsgs == nMsgs) then -+ return true -+ end -+ - if (internalState.bLiveLightGUI) then - if (nextPageUrl == nil) then - return true -- else -- cmdUrl = "http://" .. internalState.strMailServer .. "/mail/" .. nextPageUrl -+ else -+ if (string.match(nextPageUrl, "^http") == nil) then -+ cmdUrl = "http://" .. internalState.strMailServer .. "/mail/" .. nextPageUrl -+ end -+ cmdUrlPost = nextPageUrlPost - return false - end - end -- -+ - -- See if there are messages remaining - -- - if nMsgs < nTotMsgs then -@@ -1908,10 +2071,6 @@ function stat(pstate) - else - -- For western languages, our patterns don't work so use a backup pattern. - -- -- if (lastNMsgs == nMsgs) then -- return true -- end -- - if (nTotMsgs == 0 and - string.find(body, globals.strMsgListNextPagePattern) ~= nil) then - cmdUrl = baseUrl .. string.format(globals.strCmdMsgListNextPage, nPage) -@@ -1930,7 +2089,7 @@ function stat(pstate) - - -- Get the page and check to see if we got results - -- -- local body, err = getPage(browser, cmdUrl, nil, "STAT Page - LiveLight and NonLive") -+ local body, err = getPage(browser, cmdUrl, cmdUrlPost, "STAT Page - LiveLight and NonLive") - if body == nil then - return body, err - end -@@ -1944,9 +2103,21 @@ function stat(pstate) - - -- Is the session expired - -- -- local strSessExpr = string.match(body, globals.strRetLoginSessionExpired) -- local strSessExprLight = string.match(body, globals.strRetLoginSessionExpiredLiveLight) -- if strSessExpr ~= nil or strSessExprLight == nil then -+ -- dhh 2008-07-05: fix for non live light interface. -+ local bSessionExpired = false -+ if (internalState.bLiveLightGUI == false) then -+ local strSessExpr = string.match(body, globals.strRetLoginSessionExpired) -+ if strSessExpr ~= nil then -+ bSessionExpired = true -+ end -+ else -+ local strSessExprLight = string.match(body, globals.strRetLoginSessionExpiredLiveLight) -+ local strSessExprLive = string.match(body, globals.strRetLoginSessionExpiredLive) -+ if strSessExprLight == nil and strSessExprLive == nil then -+ bSessionExpired = true -+ end -+ end -+ if bSessionExpired == true then - -- Invalidate the session - -- - internalState.bLoginDone = nil -@@ -1981,6 +2152,16 @@ function stat(pstate) - return getPage(browser, cmdUrl, nil, "STAT Page - LiveLight and NonLive") - end - -+ -- cdmackie 2008-07-02: live light needs crumb now -+ if (internalState.bLiveLightGUI) then -+ if internalState.strCrumb == "" then -+ internalState.strCrumb = string.match(body, globals.strRegExpCrumbLiveLight) -+ end -+ if internalState.strUserId == "" then -+ internalState.strUserId = string.match(body, globals.strRegExpUserLiveLight) -+ end -+ end -+ - -- Get the total number of messages - -- - if nTotMsgs == 0 then -@@ -2048,8 +2229,14 @@ function stat(pstate) - -- Check to see that we completed successfully. If not, return a network - -- error. This is the safest way to let the email client now that there is - -- a problem but that it shouldn't drop the list of known uidls. -- if (nMsgs < nTotMsgs) then -- return POPSERVER_ERR_NETWORK -+ if (nMsgs < nTotMsgs and nMsgs > 0) then -+ log.error_print("The plugin needs updating. Expecting to find: " .. nTotMsgs .. -+ " and processed " .. nMsgs) -+ return POPSERVER_ERR_OK -+ elseif (nMsgs < nTotMsgs and nMsgs == 0) then -+ log.error_print("The plugin needs updating. Expecting to find: " .. nTotMsgs .. -+ " but wasn't able to process any.") -+ return POPSERVER_ERR_NETWORK - end - - -- Return that we succeeded -@@ -2057,6 +2244,34 @@ function stat(pstate) - return POPSERVER_ERR_OK - end - -+function processMessage(uidl, size, nMsgs, pstate) -+ log.dbg("Processed STAT - Msg: " .. nMsgs .. ", UIDL: " .. uidl .. ", Size: " .. size) -+ set_popstate_nummesg(pstate, nMsgs) -+ set_mailmessage_size(pstate, nMsgs, size) -+ set_mailmessage_uidl(pstate, nMsgs, uidl) -+end -+ -+function parseSize(size) -+ -- Convert the size from it's string (4KB or 2MB) to bytes -+ -- First figure out the unit (KB or just B) -+ -- -+ local kbUnit = string.match(size, "([Kk])") -+ size = string.match(size, "([%d%.,]+)%s*[KkMm]") -- cdmackie 2008-07-02: fix for space -+ if (size ~= nil) then -+ size = string.gsub(size, ",", ".") -+ end -+ if (size ~= nil and tonumber(size) ~= nil) then -+ if not kbUnit then -+ size = math.max(tonumber(size), 0) * 1024 * 1024 -+ else -+ size = math.max(tonumber(size), 0) * 1024 -+ end -+ else -+ size = 1024 -+ end -+ return size -+end -+ - -- Fill msg uidl field - -- - function uidl(pstate,msg) |