2 using System.Collections.Generic;
\r
4 using System.Threading;
\r
5 using NT2chView.NtNet;
\r
11 const string SESSION_ID_KEY = "SESSION-ID=";
\r
12 static string mSessionId;
\r
13 static object mLockThis;
\r
15 public static void init()
\r
17 mSessionId = string.Empty;
\r
18 mLockThis = new object();
\r
22 public static string getSessionId()
\r
24 string id = string.Empty;
\r
27 if (mSessionId.Length == 0)
\r
34 public static bool login()
\r
36 if (!NTUserPreference.MaruIsEnabled)
\r
39 string uid = NTUserPreference.MaruID;
\r
40 string passwd = NTUserPreference.MaruPSS;
\r
41 if (uid == null || passwd == null)
\r
43 if (uid.Length == 0 || passwd.Length == 0)
\r
48 string result = NTHttpAccess.loginMaru(uid, passwd);
\r
50 if (result == null || result.Length == 0)
\r
53 int idx = result.IndexOf(SESSION_ID_KEY);
\r
56 idx += SESSION_ID_KEY.Length;
\r
57 int idx2 = result.IndexOf(':', idx);
\r
61 string agent = result.Substring(idx, idx2-idx).Trim();
\r
62 //string sessionKey = result.Substring(idx2 + 1).Trim();
\r
63 string sessionKey = result.Substring(idx).Trim();
\r
64 if (agent.Length == 0 || sessionKey.Length == 0)
\r
67 if (0 <= agent.IndexOf("ERROR", StringComparison.CurrentCultureIgnoreCase))
\r
71 if (!NTHttpAccess.HTTP_HEADER_USER_AGENT.Equals(agent))
\r
73 NTDebug.l("UserAgent Unmatched.");
\r
77 mSessionId = NTTextUtiles.percentEncode(sessionKey);
\r
78 //mSessionId = sessionKey;
\r
82 return (mSessionId.Length > 0) ? true : false;
\r
85 public static void loginAsync()
\r
87 Thread t = new Thread(loginAsync_DoWord);
\r
91 static void loginAsync_DoWord()
\r