WOLLoginMenu.cpp 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535
  1. /*
  2. ** Command & Conquer Generals Zero Hour(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. ////////////////////////////////////////////////////////////////////////////////
  19. // //
  20. // (c) 2001-2003 Electronic Arts Inc. //
  21. // //
  22. ////////////////////////////////////////////////////////////////////////////////
  23. ///////////////////////////////////////////////////////////////////////////////////////
  24. // FILE: WOLLoginMenu.cpp
  25. // Author: Chris Huybregts, November 2001
  26. // Description: Lan Lobby Menu
  27. ///////////////////////////////////////////////////////////////////////////////////////
  28. // INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
  29. #include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine
  30. #include "Common/STLTypedefs.h"
  31. #include "Common/File.h"
  32. #include "Common/FileSystem.h"
  33. #include "Common/GameEngine.h"
  34. #include "Common/GameSpyMiscPreferences.h"
  35. #include "Common/QuotedPrintable.h"
  36. #include "Common/Registry.h"
  37. #include "Common/UserPreferences.h"
  38. #include "GameClient/AnimateWindowManager.h"
  39. #include "GameClient/WindowLayout.h"
  40. #include "GameClient/Gadget.h"
  41. #include "GameClient/GameText.h"
  42. #include "GameClient/Shell.h"
  43. #include "GameClient/KeyDefs.h"
  44. #include "GameClient/GameWindowManager.h"
  45. #include "GameClient/GadgetListBox.h"
  46. #include "GameClient/GadgetComboBox.h"
  47. #include "GameClient/GadgetCheckBox.h"
  48. #include "GameClient/GadgetStaticText.h"
  49. #include "GameClient/GadgetTextEntry.h"
  50. #include "GameClient/MessageBox.h"
  51. #include "GameClient/ShellHooks.h"
  52. #include "GameClient/GameWindowTransitions.h"
  53. #include "GameNetwork/GameSpy/GSConfig.h"
  54. #include "GameNetwork/GameSpy/PeerDefs.h"
  55. #include "GameNetwork/GameSpy/PeerThread.h"
  56. #include "GameNetwork/GameSpy/PingThread.h"
  57. #include "GameNetwork/GameSpy/BuddyThread.h"
  58. #include "GameNetwork/GameSpy/ThreadUtils.h"
  59. #include "GameNetwork/GameSpy/PersistentStorageThread.h"
  60. #include "GameNetwork/GameSpyOverlay.h"
  61. #include "GameNetwork/WOLBrowser/WebBrowser.h"
  62. #ifdef _INTERNAL
  63. // for occasional debugging...
  64. //#pragma optimize("", off)
  65. //#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes")
  66. #endif
  67. #ifdef ALLOW_NON_PROFILED_LOGIN
  68. Bool GameSpyUseProfiles = false;
  69. #endif // ALLOW_NON_PROFILED_LOGIN
  70. static Bool webBrowserActive = FALSE;
  71. static Bool useWebBrowserForTOS = FALSE;
  72. static Bool isShuttingDown = false;
  73. static Bool buttonPushed = false;
  74. static char *nextScreen = NULL;
  75. static const UnsignedInt loginTimeoutInMS = 10000;
  76. static UnsignedInt loginAttemptTime = 0;
  77. class GameSpyLoginPreferences : public UserPreferences
  78. {
  79. public:
  80. GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); }
  81. virtual ~GameSpyLoginPreferences() { m_emailPasswordMap.clear(); m_emailNickMap.clear(); }
  82. virtual Bool load(AsciiString fname);
  83. virtual Bool write(void);
  84. AsciiString getPasswordForEmail( AsciiString email );
  85. AsciiString getDateForEmail( AsciiString email, AsciiString &month, AsciiString &date, AsciiString &year );
  86. AsciiStringList getNicksForEmail( AsciiString email );
  87. void addLogin( AsciiString email, AsciiString nick, AsciiString password, AsciiString date );
  88. void forgetLogin( AsciiString email );
  89. AsciiStringList getEmails( void );
  90. private:
  91. typedef std::map<AsciiString, AsciiString> PassMap;
  92. typedef std::map<AsciiString, AsciiString> DateMap;
  93. typedef std::map<AsciiString, AsciiStringList> NickMap;
  94. PassMap m_emailPasswordMap;
  95. NickMap m_emailNickMap;
  96. DateMap m_emailDateMap;
  97. };
  98. static AsciiString obfuscate( AsciiString in )
  99. {
  100. char *buf = NEW char[in.getLength() + 1];
  101. strcpy(buf, in.str());
  102. static const char *xor = "1337Munkee";
  103. char *c = buf;
  104. const char *c2 = xor;
  105. while (*c)
  106. {
  107. if (!*c2)
  108. c2 = xor;
  109. if (*c != *c2)
  110. *c = *c++ ^ *c2++;
  111. else
  112. c++, c2++;
  113. }
  114. AsciiString out = buf;
  115. delete buf;
  116. return out;
  117. }
  118. Bool GameSpyLoginPreferences::load( AsciiString fname )
  119. {
  120. if (!UserPreferences::load(fname))
  121. return false;
  122. UserPreferences::iterator upIt = begin();
  123. while (upIt != end())
  124. {
  125. AsciiString key = upIt->first;
  126. if (key.startsWith("pass_"))
  127. {
  128. AsciiString email, pass;
  129. email = key.str() + 5;
  130. pass = upIt->second;
  131. AsciiString quoPass = QuotedPrintableToAsciiString(pass);
  132. pass = obfuscate(quoPass);
  133. m_emailPasswordMap[email] = pass;
  134. }
  135. if (key.startsWith("date_"))
  136. {
  137. AsciiString email, date;
  138. email = key.str() + 5;
  139. date = upIt->second;
  140. date = QuotedPrintableToAsciiString(date);
  141. m_emailDateMap[email] = date;
  142. }
  143. else if (key.startsWith("nick_"))
  144. {
  145. AsciiString email, nick, nicks;
  146. email = key.str() + 5;
  147. nicks = upIt->second;
  148. while (nicks.nextToken(&nick, ","))
  149. {
  150. m_emailNickMap[email].push_back(nick);
  151. }
  152. }
  153. ++upIt;
  154. }
  155. return true;
  156. }
  157. Bool GameSpyLoginPreferences::write( void )
  158. {
  159. if (m_filename.isEmpty())
  160. return false;
  161. FILE *fp = fopen(m_filename.str(), "w");
  162. if (fp)
  163. {
  164. fprintf(fp, "lastEmail = %s\n", ((*this)["lastEmail"].str()));
  165. fprintf(fp, "lastName = %s\n", ((*this)["lastName"].str()));
  166. fprintf(fp, "useProfiles = %s\n", ((*this)["useProfiles"].str()));
  167. PassMap::iterator passIt = m_emailPasswordMap.begin();
  168. while (passIt != m_emailPasswordMap.end())
  169. {
  170. AsciiString pass = obfuscate(passIt->second);
  171. AsciiString quoPass = AsciiStringToQuotedPrintable(pass);
  172. fprintf(fp, "pass_%s = %s\n", passIt->first.str(), quoPass.str());
  173. ++passIt;
  174. }
  175. PassMap::iterator dateIt = m_emailDateMap.begin();
  176. while (dateIt != m_emailDateMap.end())
  177. {
  178. AsciiString date = AsciiStringToQuotedPrintable(dateIt->second);
  179. fprintf(fp, "date_%s = %s\n", dateIt->first.str(), date.str());
  180. ++dateIt;
  181. }
  182. NickMap::iterator nickIt = m_emailNickMap.begin();
  183. while (nickIt != m_emailNickMap.end())
  184. {
  185. AsciiString nicks;
  186. AsciiStringListIterator listIt = nickIt->second.begin();
  187. while (listIt != nickIt->second.end())
  188. {
  189. nicks.concat(*listIt);
  190. nicks.concat(',');
  191. ++listIt;
  192. }
  193. fprintf(fp, "nick_%s = %s\n", nickIt->first.str(), nicks.str());
  194. ++nickIt;
  195. }
  196. fclose(fp);
  197. return true;
  198. }
  199. return false;
  200. }
  201. AsciiString GameSpyLoginPreferences::getDateForEmail( AsciiString email, AsciiString &month, AsciiString &date, AsciiString &year )
  202. {
  203. if ( m_emailDateMap.find(email) == m_emailDateMap.end() )
  204. return AsciiString::TheEmptyString;
  205. AsciiString fullDate = m_emailDateMap[email];
  206. if(fullDate.getLength() != 8)
  207. return AsciiString::TheEmptyString;
  208. month.format("%c%c", fullDate.getCharAt(0), fullDate.getCharAt(1));
  209. date.format("%c%c", fullDate.getCharAt(2), fullDate.getCharAt(3));
  210. year.format("%c%c%c%c", fullDate.getCharAt(4), fullDate.getCharAt(5), fullDate.getCharAt(6), fullDate.getCharAt(7));
  211. return m_emailDateMap[email];
  212. }
  213. AsciiString GameSpyLoginPreferences::getPasswordForEmail( AsciiString email )
  214. {
  215. if ( m_emailPasswordMap.find(email) == m_emailPasswordMap.end() )
  216. return AsciiString::TheEmptyString;
  217. return m_emailPasswordMap[email];
  218. }
  219. AsciiStringList GameSpyLoginPreferences::getNicksForEmail( AsciiString email )
  220. {
  221. if ( m_emailNickMap.find(email) == m_emailNickMap.end() )
  222. {
  223. AsciiStringList empty;
  224. return empty;
  225. }
  226. return m_emailNickMap[email];
  227. }
  228. void GameSpyLoginPreferences::addLogin( AsciiString email, AsciiString nick, AsciiString password, AsciiString date )
  229. {
  230. if ( std::find(m_emailNickMap[email].begin(), m_emailNickMap[email].end(), nick) == m_emailNickMap[email].end() )
  231. m_emailNickMap[email].push_back(nick);
  232. m_emailPasswordMap[email] = password;
  233. m_emailDateMap[email] = date;
  234. }
  235. void GameSpyLoginPreferences::forgetLogin( AsciiString email )
  236. {
  237. m_emailNickMap.erase(email);
  238. m_emailPasswordMap.erase(email);
  239. m_emailDateMap.erase(email);
  240. }
  241. AsciiStringList GameSpyLoginPreferences::getEmails( void )
  242. {
  243. AsciiStringList theList;
  244. NickMap::iterator it = m_emailNickMap.begin();
  245. while (it != m_emailNickMap.end())
  246. {
  247. theList.push_back(it->first);
  248. ++it;
  249. }
  250. return theList;
  251. }
  252. static const char *PREF_FILENAME = "GameSpyLogin.ini";
  253. static GameSpyLoginPreferences *loginPref = NULL;
  254. static void startPings( void )
  255. {
  256. std::list<AsciiString> pingServers = TheGameSpyConfig->getPingServers();
  257. Int timeout = TheGameSpyConfig->getPingTimeoutInMs();
  258. Int reps = TheGameSpyConfig->getNumPingRepetitions();
  259. for (std::list<AsciiString>::const_iterator it = pingServers.begin(); it != pingServers.end(); ++it)
  260. {
  261. AsciiString pingServer = *it;
  262. PingRequest req;
  263. req.hostname = pingServer.str();
  264. req.repetitions = reps;
  265. req.timeout = timeout;
  266. ThePinger->addRequest(req);
  267. }
  268. }
  269. //-------------------------------------------------------------------------------------------------
  270. /** This is called when a shutdown is complete for this menu */
  271. //-------------------------------------------------------------------------------------------------
  272. static void shutdownComplete( WindowLayout *layout )
  273. {
  274. isShuttingDown = false;
  275. // hide the layout
  276. layout->hide( TRUE );
  277. // our shutdown is complete
  278. TheShell->shutdownComplete( layout, (nextScreen != NULL) );
  279. if (nextScreen != NULL)
  280. {
  281. if (loginPref)
  282. {
  283. loginPref->write();
  284. delete loginPref;
  285. loginPref = NULL;
  286. }
  287. TheShell->push(nextScreen);
  288. }
  289. else
  290. {
  291. DEBUG_ASSERTCRASH(loginPref != NULL, ("loginPref == NULL"));
  292. if (loginPref)
  293. {
  294. loginPref->write();
  295. delete loginPref;
  296. loginPref = NULL;
  297. }
  298. }
  299. nextScreen = NULL;
  300. } // end if
  301. // PRIVATE DATA ///////////////////////////////////////////////////////////////////////////////////
  302. // window ids ------------------------------------------------------------------------------
  303. static NameKeyType parentWOLLoginID = NAMEKEY_INVALID;
  304. static NameKeyType buttonBackID = NAMEKEY_INVALID; // profile, quick
  305. static NameKeyType buttonLoginID = NAMEKEY_INVALID; // profile, quick
  306. static NameKeyType buttonCreateAccountID = NAMEKEY_INVALID; // profile, quick
  307. static NameKeyType buttonUseAccountID = NAMEKEY_INVALID; // quick
  308. static NameKeyType buttonDontUseAccountID = NAMEKEY_INVALID; // profile
  309. static NameKeyType buttonTOSID = NAMEKEY_INVALID; // TOS
  310. static NameKeyType parentTOSID = NAMEKEY_INVALID; // TOS Parent
  311. static NameKeyType buttonTOSOKID = NAMEKEY_INVALID; // TOS
  312. static NameKeyType listboxTOSID = NAMEKEY_INVALID; // TOS
  313. static NameKeyType comboBoxEmailID = NAMEKEY_INVALID; // profile
  314. static NameKeyType comboBoxLoginNameID = NAMEKEY_INVALID; // profile
  315. static NameKeyType textEntryLoginNameID = NAMEKEY_INVALID; // quick
  316. static NameKeyType textEntryPasswordID = NAMEKEY_INVALID; // profile
  317. static NameKeyType checkBoxRememberPasswordID = NAMEKEY_INVALID; // checkbox to remember information or not
  318. static NameKeyType textEntryMonthID = NAMEKEY_INVALID; // profile
  319. static NameKeyType textEntryDayID = NAMEKEY_INVALID; // profile
  320. static NameKeyType textEntryYearID = NAMEKEY_INVALID; // profile
  321. // Window Pointers ------------------------------------------------------------------------
  322. static GameWindow *parentWOLLogin = NULL;
  323. static GameWindow *buttonBack = NULL;
  324. static GameWindow *buttonLogin = NULL;
  325. static GameWindow *buttonCreateAccount = NULL;
  326. static GameWindow *buttonUseAccount = NULL;
  327. static GameWindow *buttonDontUseAccount = NULL;
  328. static GameWindow *buttonTOS = NULL;
  329. static GameWindow *parentTOS = NULL;
  330. static GameWindow *buttonTOSOK = NULL;
  331. static GameWindow *listboxTOS = NULL;
  332. static GameWindow *comboBoxEmail = NULL;
  333. static GameWindow *comboBoxLoginName = NULL;
  334. static GameWindow *textEntryLoginName = NULL;
  335. static GameWindow *textEntryPassword = NULL;
  336. static GameWindow *checkBoxRememberPassword = NULL;
  337. static GameWindow *textEntryMonth = NULL;
  338. static GameWindow *textEntryDay = NULL;
  339. static GameWindow *textEntryYear = NULL;
  340. void EnableLoginControls( Bool state )
  341. {
  342. if (buttonLogin)
  343. buttonLogin->winEnable(state);
  344. if (buttonCreateAccount)
  345. buttonCreateAccount->winEnable(state);
  346. if (buttonUseAccount)
  347. buttonUseAccount->winEnable(state);
  348. if (buttonDontUseAccount)
  349. buttonDontUseAccount->winEnable(state);
  350. if (comboBoxEmail)
  351. comboBoxEmail->winEnable(state);
  352. if (comboBoxLoginName)
  353. comboBoxLoginName->winEnable(state);
  354. if (textEntryLoginName)
  355. textEntryLoginName->winEnable(state);
  356. if (textEntryPassword)
  357. textEntryPassword->winEnable(state);
  358. if (checkBoxRememberPassword)
  359. checkBoxRememberPassword->winEnable(state);
  360. if( buttonTOS )
  361. buttonTOS->winEnable(state);
  362. if (textEntryMonth)
  363. textEntryMonth->winEnable(state);
  364. if (textEntryDay)
  365. textEntryDay->winEnable(state);
  366. if( textEntryYear )
  367. textEntryYear->winEnable(state);
  368. }
  369. //-------------------------------------------------------------------------------------------------
  370. /** Initialize the WOL Login Menu */
  371. //-------------------------------------------------------------------------------------------------
  372. void WOLLoginMenuInit( WindowLayout *layout, void *userData )
  373. {
  374. nextScreen = NULL;
  375. buttonPushed = false;
  376. isShuttingDown = false;
  377. loginAttemptTime = 0;
  378. if (!loginPref)
  379. {
  380. loginPref = NEW GameSpyLoginPreferences;
  381. loginPref->load(PREF_FILENAME);
  382. }
  383. // if the ESRB warning is blank (other country) hide the box
  384. GameWindow *esrbTitle = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("GameSpyLoginProfile.wnd:StaticTextESRBTop") );
  385. GameWindow *esrbParent = TheWindowManager->winGetWindowFromId( NULL, NAMEKEY("GameSpyLoginProfile.wnd:ParentESRB") );
  386. if (esrbTitle && esrbParent)
  387. {
  388. if ( GadgetStaticTextGetText( esrbTitle ).getLength() < 2 )
  389. {
  390. esrbParent->winHide(TRUE);
  391. }
  392. }
  393. parentWOLLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:WOLLoginMenuParent" );
  394. buttonBackID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonBack" );
  395. buttonLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonLogin" );
  396. buttonCreateAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonCreateAccount" );
  397. buttonUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonUseAccount" );
  398. buttonDontUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonDontUseAccount" );
  399. buttonTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonTOS" );
  400. parentTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ParentTOS" );
  401. buttonTOSOKID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ButtonTOSOK" );
  402. listboxTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ListboxTOS" );
  403. comboBoxEmailID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ComboBoxEmail" );
  404. comboBoxLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:ComboBoxLoginName" );
  405. textEntryLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryLoginName" );
  406. textEntryPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryPassword" );
  407. checkBoxRememberPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:CheckBoxRememberInfo" );
  408. textEntryMonthID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryMonth" );
  409. textEntryDayID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryDay" );
  410. textEntryYearID = TheNameKeyGenerator->nameToKey( "GameSpyLoginProfile.wnd:TextEntryYear" );
  411. parentWOLLogin = TheWindowManager->winGetWindowFromId( NULL, parentWOLLoginID );
  412. buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID);
  413. buttonLogin = TheWindowManager->winGetWindowFromId( NULL, buttonLoginID);
  414. buttonCreateAccount = TheWindowManager->winGetWindowFromId( NULL, buttonCreateAccountID);
  415. buttonUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonUseAccountID);
  416. buttonDontUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonDontUseAccountID);
  417. buttonTOS = TheWindowManager->winGetWindowFromId( NULL, buttonTOSID);
  418. parentTOS = TheWindowManager->winGetWindowFromId( NULL, parentTOSID);
  419. buttonTOSOK = TheWindowManager->winGetWindowFromId( NULL, buttonTOSOKID);
  420. listboxTOS = TheWindowManager->winGetWindowFromId( NULL, listboxTOSID);
  421. comboBoxEmail = TheWindowManager->winGetWindowFromId( NULL, comboBoxEmailID);
  422. comboBoxLoginName = TheWindowManager->winGetWindowFromId( NULL, comboBoxLoginNameID);
  423. textEntryLoginName = TheWindowManager->winGetWindowFromId( NULL, textEntryLoginNameID);
  424. textEntryPassword = TheWindowManager->winGetWindowFromId( NULL, textEntryPasswordID);
  425. checkBoxRememberPassword = TheWindowManager->winGetWindowFromId( NULL, checkBoxRememberPasswordID);
  426. textEntryMonth = TheWindowManager->winGetWindowFromId( NULL, textEntryMonthID);
  427. textEntryDay = TheWindowManager->winGetWindowFromId( NULL, textEntryDayID);
  428. textEntryYear = TheWindowManager->winGetWindowFromId( NULL, textEntryYearID);
  429. GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString);
  430. GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString);
  431. GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString);
  432. GameWindowList tabList;
  433. tabList.push_front(comboBoxEmail);
  434. tabList.push_back(comboBoxLoginName);
  435. tabList.push_back(textEntryPassword);
  436. tabList.push_back(textEntryMonth);
  437. tabList.push_back(textEntryDay);
  438. tabList.push_back(textEntryYear);
  439. tabList.push_back(checkBoxRememberPassword);
  440. tabList.push_back(buttonLogin);
  441. tabList.push_back(buttonCreateAccount);
  442. tabList.push_back(buttonTOS);
  443. tabList.push_back(buttonBack);
  444. TheWindowManager->clearTabList();
  445. TheWindowManager->registerTabList(tabList);
  446. TheWindowManager->winSetFocus( comboBoxEmail );
  447. // short form or long form?
  448. #ifdef ALLOW_NON_PROFILED_LOGIN
  449. if (parentWOLLogin)
  450. {
  451. GameSpyUseProfiles = true;
  452. #endif // ALLOW_NON_PROFILED_LOGIN
  453. DEBUG_ASSERTCRASH(buttonBack, ("buttonBack missing!"));
  454. DEBUG_ASSERTCRASH(buttonLogin, ("buttonLogin missing!"));
  455. DEBUG_ASSERTCRASH(buttonCreateAccount, ("buttonCreateAccount missing!"));
  456. //DEBUG_ASSERTCRASH(buttonDontUseAccount, ("buttonDontUseAccount missing!"));
  457. DEBUG_ASSERTCRASH(comboBoxEmail, ("comboBoxEmail missing!"));
  458. DEBUG_ASSERTCRASH(comboBoxLoginName, ("comboBoxLoginName missing!"));
  459. DEBUG_ASSERTCRASH(textEntryPassword, ("textEntryPassword missing!"));
  460. //TheShell->registerWithAnimateManager(parentWOLLogin, WIN_ANIMATION_SLIDE_TOP, TRUE);
  461. /**/
  462. // TheShell->registerWithAnimateManager(buttonTOS, WIN_ANIMATION_SLIDE_BOTTOM, TRUE);
  463. //TheShell->registerWithAnimateManager(buttonCreateAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE);
  464. //TheShell->registerWithAnimateManager(buttonDontUseAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE);
  465. // TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_BOTTOM, TRUE);
  466. /**/
  467. #ifdef ALLOW_NON_PROFILED_LOGIN
  468. }
  469. else
  470. {
  471. GameSpyUseProfiles = false;
  472. parentWOLLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:WOLLoginMenuParent" );
  473. buttonBackID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonBack" );
  474. buttonLoginID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonLogin" );
  475. buttonCreateAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonCreateAccount" );
  476. buttonUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonUseAccount" );
  477. buttonDontUseAccountID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonDontUseAccount" );
  478. buttonTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonTOS" );
  479. parentTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ParentTOS" );
  480. buttonTOSOKID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ButtonTOSOK" );
  481. listboxTOSID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ListboxTOS" );
  482. comboBoxEmailID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:ComboBoxEmail" );
  483. textEntryLoginNameID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:TextEntryLoginName" );
  484. textEntryPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:TextEntryPassword" );
  485. checkBoxRememberPasswordID = TheNameKeyGenerator->nameToKey( "GameSpyLoginQuick.wnd:CheckBoxRememberPassword" );
  486. parentWOLLogin = TheWindowManager->winGetWindowFromId( NULL, parentWOLLoginID );
  487. buttonBack = TheWindowManager->winGetWindowFromId( NULL, buttonBackID);
  488. buttonLogin = TheWindowManager->winGetWindowFromId( NULL, buttonLoginID);
  489. buttonCreateAccount = TheWindowManager->winGetWindowFromId( NULL, buttonCreateAccountID);
  490. buttonUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonUseAccountID);
  491. buttonDontUseAccount = TheWindowManager->winGetWindowFromId( NULL, buttonDontUseAccountID);
  492. comboBoxEmail = TheWindowManager->winGetWindowFromId( NULL, comboBoxEmailID);
  493. buttonTOS = TheWindowManager->winGetWindowFromId( NULL, buttonTOSID);
  494. parentTOS = TheWindowManager->winGetWindowFromId( NULL, parentTOSID);
  495. buttonTOSOK = TheWindowManager->winGetWindowFromId( NULL, buttonTOSOKID);
  496. listboxTOS = TheWindowManager->winGetWindowFromId( NULL, listboxTOSID);
  497. textEntryLoginName = TheWindowManager->winGetWindowFromId( NULL, textEntryLoginNameID);
  498. textEntryPassword = TheWindowManager->winGetWindowFromId( NULL, textEntryPasswordID);
  499. checkBoxRememberPassword = TheWindowManager->winGetWindowFromId( NULL, checkBoxRememberPasswordID);
  500. DEBUG_ASSERTCRASH(buttonBack, ("buttonBack missing!"));
  501. DEBUG_ASSERTCRASH(buttonLogin, ("buttonLogin missing!"));
  502. DEBUG_ASSERTCRASH(buttonCreateAccount, ("buttonCreateAccount missing!"));
  503. DEBUG_ASSERTCRASH(buttonUseAccount, ("buttonUseAccount missing!"));
  504. DEBUG_ASSERTCRASH(textEntryLoginName, ("textEntryLoginName missing!"));
  505. TheWindowManager->winSetFocus( textEntryLoginName );
  506. //TheShell->registerWithAnimateManager(parentWOLLogin, WIN_ANIMATION_SLIDE_TOP, TRUE);
  507. // TheShell->registerWithAnimateManager(buttonTOS, WIN_ANIMATION_SLIDE_LEFT, TRUE);
  508. // TheShell->registerWithAnimateManager(buttonCreateAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE);
  509. // TheShell->registerWithAnimateManager(buttonUseAccount, WIN_ANIMATION_SLIDE_LEFT, TRUE);
  510. // TheShell->registerWithAnimateManager(buttonBack, WIN_ANIMATION_SLIDE_RIGHT, TRUE);
  511. }
  512. #endif // ALLOW_NON_PROFILED_LOGIN
  513. #ifdef ALLOW_NON_PROFILED_LOGIN
  514. if (GameSpyUseProfiles)
  515. {
  516. #endif // ALLOW_NON_PROFILED_LOGIN
  517. // Read login names from registry...
  518. GadgetComboBoxReset(comboBoxEmail);
  519. GadgetTextEntrySetText(textEntryPassword, UnicodeString.TheEmptyString);
  520. // look for cached nicks to add
  521. AsciiString lastName;
  522. AsciiString lastEmail;
  523. Bool markCheckBox = FALSE;
  524. UserPreferences::const_iterator it = loginPref->find("lastName");
  525. if (it != loginPref->end())
  526. {
  527. lastName = it->second;
  528. }
  529. it = loginPref->find("lastEmail");
  530. if (it != loginPref->end())
  531. {
  532. lastEmail = it->second;
  533. }
  534. // fill in list of Emails, and select the most recent
  535. AsciiStringList cachedEmails = loginPref->getEmails();
  536. AsciiStringListIterator eIt = cachedEmails.begin();
  537. Int selectedPos = -1;
  538. while (eIt != cachedEmails.end())
  539. {
  540. UnicodeString uniEmail;
  541. uniEmail.translate(*eIt);
  542. Int pos = GadgetComboBoxAddEntry(comboBoxEmail, uniEmail, GameSpyColor[GSCOLOR_DEFAULT]);
  543. if (*eIt == lastEmail)
  544. selectedPos = pos;
  545. ++eIt;
  546. }
  547. if (selectedPos >= 0)
  548. {
  549. GadgetComboBoxSetSelectedPos(comboBoxEmail, selectedPos);
  550. // fill in the password for the selected email
  551. UnicodeString pass;
  552. pass.translate(loginPref->getPasswordForEmail(lastEmail));
  553. GadgetTextEntrySetText(textEntryPassword, pass);
  554. AsciiString month,day,year;
  555. loginPref->getDateForEmail(lastEmail, month, day, year);
  556. pass.translate(month);
  557. GadgetTextEntrySetText(textEntryMonth, pass);
  558. pass.translate(day);
  559. GadgetTextEntrySetText(textEntryDay, pass);
  560. pass.translate(year);
  561. GadgetTextEntrySetText(textEntryYear, pass);
  562. markCheckBox = TRUE;
  563. }
  564. // fill in list of nicks for selected email, selecting the most recent
  565. GadgetComboBoxReset(comboBoxLoginName);
  566. AsciiStringList cachedNicks = loginPref->getNicksForEmail(lastEmail);
  567. AsciiStringListIterator nIt = cachedNicks.begin();
  568. selectedPos = -1;
  569. while (nIt != cachedNicks.end())
  570. {
  571. UnicodeString uniNick;
  572. uniNick.translate(*nIt);
  573. Int pos = GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]);
  574. if (*nIt == lastName)
  575. selectedPos = pos;
  576. ++nIt;
  577. }
  578. if (selectedPos >= 0)
  579. {
  580. GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos);
  581. markCheckBox = TRUE;
  582. }
  583. // always start with not storing information
  584. if( markCheckBox)
  585. GadgetCheckBoxSetChecked(checkBoxRememberPassword, TRUE);
  586. else
  587. GadgetCheckBoxSetChecked(checkBoxRememberPassword, FALSE);
  588. #ifdef ALLOW_NON_PROFILED_LOGIN
  589. }
  590. else
  591. {
  592. // Read login names from registry...
  593. GadgetComboBoxReset(comboBoxLoginName);
  594. UnicodeString nick;
  595. UserPreferences::const_iterator it = loginPref->find("lastName");
  596. if (it != loginPref->end())
  597. {
  598. nick.translate(it->second);
  599. }
  600. else
  601. {
  602. char userBuf[32] = "";
  603. unsigned long bufSize = 32;
  604. GetUserName(userBuf, &bufSize);
  605. nick.translate(userBuf);
  606. }
  607. GadgetTextEntrySetText(textEntryLoginName, nick);
  608. }
  609. #endif // ALLOW_NON_PROFILED_LOGIN
  610. EnableLoginControls(TRUE);
  611. // Show Menu
  612. layout->hide( FALSE );
  613. // Set Keyboard to Main Parent
  614. RaiseGSMessageBox();
  615. OptionPreferences optionPref;
  616. if (!optionPref.getBool("SawTOS", TRUE))
  617. {
  618. TheWindowManager->winSendSystemMsg( parentWOLLogin, GBM_SELECTED,
  619. (WindowMsgData)buttonTOS, buttonTOSID );
  620. }
  621. TheTransitionHandler->setGroup("GameSpyLoginProfileFade");
  622. } // WOLLoginMenuInit
  623. //-------------------------------------------------------------------------------------------------
  624. /** WOL Login Menu shutdown method */
  625. //-------------------------------------------------------------------------------------------------
  626. static Bool loggedInOK = false;
  627. void WOLLoginMenuShutdown( WindowLayout *layout, void *userData )
  628. {
  629. isShuttingDown = true;
  630. loggedInOK = false;
  631. TheWindowManager->clearTabList();
  632. if (webBrowserActive)
  633. {
  634. if (TheWebBrowser != NULL)
  635. {
  636. TheWebBrowser->closeBrowserWindow(listboxTOS);
  637. }
  638. webBrowserActive = FALSE;
  639. }
  640. // if we are shutting down for an immediate pop, skip the animations
  641. Bool popImmediate = *(Bool *)userData;
  642. if( popImmediate )
  643. {
  644. shutdownComplete( layout );
  645. return;
  646. } //end if
  647. TheShell->reverseAnimatewindow();
  648. TheTransitionHandler->reverse("GameSpyLoginProfileFade");
  649. } // WOLLoginMenuShutdown
  650. // this is used to check if we've got all the pings
  651. static void checkLogin( void )
  652. {
  653. if (loggedInOK && ThePinger && !ThePinger->arePingsInProgress())
  654. {
  655. // save off our ping string, and end those threads
  656. AsciiString pingStr = ThePinger->getPingString( 1000 );
  657. DEBUG_LOG(("Ping string is %s\n", pingStr.str()));
  658. TheGameSpyInfo->setPingString(pingStr);
  659. //delete ThePinger;
  660. //ThePinger = NULL;
  661. buttonPushed = true;
  662. loggedInOK = false; // don't try this again
  663. loginAttemptTime = 0;
  664. // start looking for group rooms
  665. TheGameSpyInfo->clearGroupRoomList();
  666. SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_LOGIN);
  667. nextScreen = "Menus/WOLWelcomeMenu.wnd";
  668. TheShell->pop();
  669. // read in some cached data
  670. GameSpyMiscPreferences mPref;
  671. PSPlayerStats localPSStats = GameSpyPSMessageQueueInterface::parsePlayerKVPairs(mPref.getCachedStats().str());
  672. localPSStats.id = TheGameSpyInfo->getLocalProfileID();
  673. TheGameSpyInfo->setCachedLocalPlayerStats(localPSStats);
  674. // TheGameSpyPSMessageQueue->trackPlayerStats(localPSStats);
  675. // and push the info around to other players
  676. // PSResponse newResp;
  677. // newResp.responseType = PSResponse::PSRESPONSE_PLAYERSTATS;
  678. // newResp.player = localPSStats;
  679. // TheGameSpyPSMessageQueue->addResponse(newResp);
  680. }
  681. }
  682. //-------------------------------------------------------------------------------------------------
  683. /** WOL Login Menu update method */
  684. //-------------------------------------------------------------------------------------------------
  685. void WOLLoginMenuUpdate( WindowLayout * layout, void *userData)
  686. {
  687. // We'll only be successful if we've requested to
  688. if(isShuttingDown && TheShell->isAnimFinished() && TheTransitionHandler->isFinished())
  689. shutdownComplete(layout);
  690. if (TheShell->isAnimFinished() && !buttonPushed && TheGameSpyPeerMessageQueue)
  691. {
  692. PingResponse pingResp;
  693. if (ThePinger && ThePinger->getResponse(pingResp))
  694. {
  695. checkLogin();
  696. }
  697. PeerResponse resp;
  698. if (!loggedInOK && TheGameSpyPeerMessageQueue->getResponse( resp ))
  699. {
  700. switch (resp.peerResponseType)
  701. {
  702. case PeerResponse::PEERRESPONSE_GROUPROOM:
  703. {
  704. GameSpyGroupRoom room;
  705. room.m_groupID = resp.groupRoom.id;
  706. room.m_maxWaiting = resp.groupRoom.maxWaiting;
  707. room.m_name = resp.groupRoomName.c_str();
  708. room.m_translatedName = UnicodeString(L"TEST");
  709. room.m_numGames = resp.groupRoom.numGames;
  710. room.m_numPlaying = resp.groupRoom.numPlaying;
  711. room.m_numWaiting = resp.groupRoom.numWaiting;
  712. TheGameSpyInfo->addGroupRoom( room );
  713. }
  714. break;
  715. case PeerResponse::PEERRESPONSE_LOGIN:
  716. {
  717. loggedInOK = true;
  718. // fetch our player info
  719. TheGameSpyInfo->setLocalName( resp.nick.c_str() );
  720. TheGameSpyInfo->setLocalProfileID( resp.player.profileID );
  721. TheGameSpyInfo->loadSavedIgnoreList();
  722. TheGameSpyInfo->setLocalIPs(resp.player.internalIP, resp.player.externalIP);
  723. TheGameSpyInfo->readAdditionalDisconnects();
  724. //TheGameSpyInfo->setLocalEmail( resp.player.email );
  725. //TheGameSpyInfo->setLocalPassword( resp)
  726. GameSpyMiscPreferences miscPref;
  727. TheGameSpyInfo->setMaxMessagesPerUpdate(miscPref.getMaxMessagesPerUpdate());
  728. }
  729. break;
  730. case PeerResponse::PEERRESPONSE_DISCONNECT:
  731. {
  732. loginAttemptTime = 0;
  733. UnicodeString title, body;
  734. AsciiString disconMunkee;
  735. disconMunkee.format("GUI:GSDisconReason%d", resp.discon.reason);
  736. title = TheGameText->fetch( "GUI:GSErrorTitle" );
  737. body = TheGameText->fetch( disconMunkee );
  738. GSMessageBoxOk( title, body );
  739. EnableLoginControls( TRUE );
  740. // kill & restart the threads
  741. AsciiString motd = TheGameSpyInfo->getMOTD();
  742. AsciiString config = TheGameSpyInfo->getConfig();
  743. DEBUG_LOG(("Tearing down GameSpy from WOLLoginMenuUpdate(PEERRESPONSE_DISCONNECT)\n"));
  744. TearDownGameSpy();
  745. SetUpGameSpy( motd.str(), config.str() );
  746. }
  747. break;
  748. }
  749. }
  750. checkLogin();
  751. }
  752. if (TheGameSpyInfo && !buttonPushed && loginAttemptTime && (loginAttemptTime + loginTimeoutInMS < timeGetTime()))
  753. {
  754. // timed out a login attempt, so say so
  755. loginAttemptTime = 0;
  756. UnicodeString title, body;
  757. AsciiString disconMunkee;
  758. disconMunkee.format("GUI:GSDisconReason4"); // ("could not connect to server")
  759. title = TheGameText->fetch( "GUI:GSErrorTitle" );
  760. body = TheGameText->fetch( disconMunkee );
  761. GSMessageBoxOk( title, body );
  762. EnableLoginControls( TRUE );
  763. // kill & restart the threads
  764. AsciiString motd = TheGameSpyInfo->getMOTD();
  765. AsciiString config = TheGameSpyInfo->getConfig();
  766. DEBUG_LOG(("Tearing down GameSpy from WOLLoginMenuUpdate(login timeout)\n"));
  767. TearDownGameSpy();
  768. SetUpGameSpy( motd.str(), config.str() );
  769. }
  770. }// WOLLoginMenuUpdate
  771. //-------------------------------------------------------------------------------------------------
  772. /** WOL Login Menu input callback */
  773. //-------------------------------------------------------------------------------------------------
  774. WindowMsgHandledType WOLLoginMenuInput( GameWindow *window, UnsignedInt msg,
  775. WindowMsgData mData1, WindowMsgData mData2 )
  776. {
  777. switch( msg )
  778. {
  779. // --------------------------------------------------------------------------------------------
  780. case GWM_CHAR:
  781. {
  782. UnsignedByte key = mData1;
  783. UnsignedByte state = mData2;
  784. if (buttonPushed)
  785. break;
  786. switch( key )
  787. {
  788. // ----------------------------------------------------------------------------------------
  789. case KEY_ESC:
  790. {
  791. //
  792. // send a simulated selected event to the parent window of the
  793. // back/exit button
  794. //
  795. if( BitTest( state, KEY_STATE_UP ) )
  796. {
  797. TheWindowManager->winSendSystemMsg( window, GBM_SELECTED,
  798. (WindowMsgData)buttonBack, buttonBackID );
  799. } // end if
  800. // don't let key fall through anywhere else
  801. return MSG_HANDLED;
  802. } // end escape
  803. } // end switch( key )
  804. } // end char
  805. } // end switch( msg )
  806. return MSG_IGNORED;
  807. }// WOLLoginMenuInput
  808. static Bool isNickOkay(UnicodeString nick)
  809. {
  810. static const WideChar * legalIRCChars = L"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789[]`_^{|}-";
  811. Int len = nick.getLength();
  812. if (len == 0)
  813. return TRUE;
  814. if (len == 1 && nick.getCharAt(0) == L'-')
  815. return FALSE;
  816. WideChar newChar = nick.getCharAt(len-1);
  817. if (wcschr(legalIRCChars, newChar) == NULL)
  818. return FALSE;
  819. return TRUE;
  820. }
  821. static Bool isAgeOkay(AsciiString &month, AsciiString &day, AsciiString year)
  822. {
  823. if(month.isEmpty() || day.isEmpty() || year.isEmpty() || year.getLength() != 4)
  824. return FALSE;
  825. Int monthInt = atoi(month.str());
  826. Int dayInt = atoi(day.str());
  827. if(monthInt > 12 || dayInt > 31)
  828. return FALSE;
  829. // setup date buffer for local region date format
  830. month.format("%02.2d",monthInt);
  831. day.format("%02.2d",dayInt);
  832. // test the year first
  833. #define DATE_BUFFER_SIZE 256
  834. char dateBuffer[ DATE_BUFFER_SIZE ];
  835. GetDateFormat( LOCALE_SYSTEM_DEFAULT,
  836. 0, NULL,
  837. "yyyy",
  838. dateBuffer, DATE_BUFFER_SIZE );
  839. Int sysVal = atoi(dateBuffer);
  840. Int userVal = atoi(year.str());
  841. if(sysVal - userVal >= 14)
  842. return TRUE;
  843. else if( sysVal - userVal <= 12)
  844. return FALSE;
  845. GetDateFormat( LOCALE_SYSTEM_DEFAULT,
  846. 0, NULL,
  847. "MM",
  848. dateBuffer, DATE_BUFFER_SIZE );
  849. sysVal = atoi(dateBuffer);
  850. userVal = atoi(month.str());
  851. if(sysVal - userVal >0 )
  852. return TRUE;
  853. else if( sysVal -userVal < 0 )
  854. return FALSE;
  855. // month.format("%02.2d",userVal);
  856. GetDateFormat( LOCALE_SYSTEM_DEFAULT,
  857. 0, NULL,
  858. "dd",
  859. dateBuffer, DATE_BUFFER_SIZE );
  860. sysVal = atoi(dateBuffer);
  861. userVal = atoi(day.str());
  862. if(sysVal - userVal< 0)
  863. return FALSE;
  864. // day.format("%02.2d",userVal);
  865. return TRUE;
  866. }
  867. //-------------------------------------------------------------------------------------------------
  868. /** WOL Login Menu window system callback */
  869. //-------------------------------------------------------------------------------------------------
  870. WindowMsgHandledType WOLLoginMenuSystem( GameWindow *window, UnsignedInt msg,
  871. WindowMsgData mData1, WindowMsgData mData2 )
  872. {
  873. UnicodeString txtInput;
  874. switch( msg )
  875. {
  876. case GWM_CREATE:
  877. {
  878. break;
  879. } // case GWM_DESTROY:
  880. case GWM_DESTROY:
  881. {
  882. break;
  883. } // case GWM_DESTROY:
  884. case GWM_INPUT_FOCUS:
  885. {
  886. // if we're givin the opportunity to take the keyboard focus we must say we want it
  887. if( mData1 == TRUE )
  888. *(Bool *)mData2 = TRUE;
  889. return MSG_HANDLED;
  890. }//case GWM_INPUT_FOCUS:
  891. // someone typed in a combo box. Clear password (or fill it in if the typed name matches a known login name)
  892. case GCM_UPDATE_TEXT:
  893. {
  894. UnicodeString uNick = GadgetComboBoxGetText(comboBoxLoginName);
  895. UnicodeString uEmail = GadgetComboBoxGetText(comboBoxEmail);
  896. AsciiString nick, email;
  897. nick.translate(uNick);
  898. email.translate(uEmail);
  899. GameWindow *control = (GameWindow *)mData1;
  900. Int controlID = control->winGetWindowId();
  901. UnicodeString trimmedNick = uNick, trimmedEmail = uEmail;
  902. trimmedNick.trim();
  903. trimmedEmail.trim();
  904. if (!trimmedNick.isEmpty())
  905. {
  906. if (trimmedNick.getCharAt(trimmedNick.getLength()-1) == L'\\')
  907. trimmedNick.removeLastChar();
  908. if (trimmedNick.getCharAt(trimmedNick.getLength()-1) == L'/')
  909. trimmedNick.removeLastChar();
  910. }
  911. if (!trimmedEmail.isEmpty())
  912. {
  913. if (trimmedEmail.getCharAt(trimmedEmail.getLength()-1) == L'\\')
  914. trimmedEmail.removeLastChar();
  915. if (trimmedEmail.getCharAt(trimmedEmail.getLength()-1) == L'/')
  916. trimmedEmail.removeLastChar();
  917. }
  918. if (trimmedEmail.getLength() != uEmail.getLength())
  919. {
  920. // we just trimmed a space. set the text back and bail
  921. GadgetComboBoxSetText(comboBoxEmail, trimmedEmail);
  922. break;
  923. }
  924. if (trimmedNick.getLength() != nick.getLength())
  925. {
  926. // we just trimmed a space. set the text back and bail
  927. GadgetComboBoxSetText(comboBoxLoginName, trimmedNick);
  928. break;
  929. }
  930. if (controlID == comboBoxEmailID)
  931. {
  932. // email changed. look up password, and choose new login names
  933. // fill in the password for the selected email
  934. UnicodeString pass;
  935. pass.translate(loginPref->getPasswordForEmail(email));
  936. GadgetTextEntrySetText(textEntryPassword, pass);
  937. // fill in list of nicks for selected email, selecting the first
  938. AsciiStringList cachedNicks = loginPref->getNicksForEmail(email);
  939. AsciiStringListIterator nIt = cachedNicks.begin();
  940. Int selectedPos = -1;
  941. GadgetComboBoxReset(comboBoxLoginName);
  942. while (nIt != cachedNicks.end())
  943. {
  944. UnicodeString uniNick;
  945. uniNick.translate(*nIt);
  946. GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]);
  947. selectedPos = 0;
  948. ++nIt;
  949. }
  950. if (selectedPos >= 0)
  951. {
  952. GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos);
  953. GadgetCheckBoxSetChecked(checkBoxRememberPassword, true);
  954. AsciiString month,day,year;
  955. loginPref->getDateForEmail(email, month, day, year);
  956. pass.translate(month);
  957. GadgetTextEntrySetText(textEntryMonth, pass);
  958. pass.translate(day);
  959. GadgetTextEntrySetText(textEntryDay, pass);
  960. pass.translate(year);
  961. GadgetTextEntrySetText(textEntryYear, pass);
  962. }
  963. else
  964. {
  965. GadgetCheckBoxSetChecked(checkBoxRememberPassword, false);
  966. GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString);
  967. GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString);
  968. GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString);
  969. }
  970. }
  971. else if (controlID == comboBoxLoginNameID)
  972. {
  973. // they typed a new login name. Email & pass shouldn't change
  974. }
  975. break;
  976. }
  977. case GCM_SELECTED:
  978. {
  979. if (buttonPushed)
  980. break;
  981. GameWindow *control = (GameWindow *)mData1;
  982. Int controlID = control->winGetWindowId();
  983. if (controlID == comboBoxEmailID)
  984. {
  985. // email changed. look up password, and choose new login names
  986. UnicodeString uEmail = GadgetComboBoxGetText(comboBoxEmail);
  987. AsciiString email;
  988. email.translate(uEmail);
  989. // fill in the password for the selected email
  990. UnicodeString pass;
  991. pass.translate(loginPref->getPasswordForEmail(email));
  992. GadgetTextEntrySetText(textEntryPassword, pass);
  993. // fill in list of nicks for selected email, selecting the first
  994. AsciiStringList cachedNicks = loginPref->getNicksForEmail(email);
  995. AsciiStringListIterator nIt = cachedNicks.begin();
  996. Int selectedPos = -1;
  997. GadgetComboBoxReset(comboBoxLoginName);
  998. while (nIt != cachedNicks.end())
  999. {
  1000. UnicodeString uniNick;
  1001. uniNick.translate(*nIt);
  1002. GadgetComboBoxAddEntry(comboBoxLoginName, uniNick, GameSpyColor[GSCOLOR_DEFAULT]);
  1003. selectedPos = 0;
  1004. ++nIt;
  1005. }
  1006. if (selectedPos >= 0)
  1007. {
  1008. GadgetComboBoxSetSelectedPos(comboBoxLoginName, selectedPos);
  1009. GadgetCheckBoxSetChecked(checkBoxRememberPassword, true);
  1010. AsciiString month,day,year;
  1011. loginPref->getDateForEmail(email, month, day, year);
  1012. pass.translate(month);
  1013. GadgetTextEntrySetText(textEntryMonth, pass);
  1014. pass.translate(day);
  1015. GadgetTextEntrySetText(textEntryDay, pass);
  1016. pass.translate(year);
  1017. GadgetTextEntrySetText(textEntryYear, pass);
  1018. }
  1019. else
  1020. {
  1021. GadgetCheckBoxSetChecked(checkBoxRememberPassword, false);
  1022. GadgetTextEntrySetText(textEntryMonth, UnicodeString::TheEmptyString);
  1023. GadgetTextEntrySetText(textEntryDay, UnicodeString::TheEmptyString);
  1024. GadgetTextEntrySetText(textEntryYear, UnicodeString::TheEmptyString);
  1025. }
  1026. }
  1027. else if (controlID == comboBoxLoginNameID)
  1028. {
  1029. // they typed a new login name. Email & pass shouldn't change
  1030. }
  1031. break;
  1032. }
  1033. case GBM_SELECTED:
  1034. {
  1035. if (buttonPushed)
  1036. break;
  1037. GameWindow *control = (GameWindow *)mData1;
  1038. Int controlID = control->winGetWindowId();
  1039. // If we back out, just bail - we haven't gotten far enough to need to log out
  1040. if ( controlID == buttonBackID )
  1041. {
  1042. buttonPushed = true;
  1043. TearDownGameSpy();
  1044. TheShell->pop();
  1045. } //if ( controlID == buttonBack )
  1046. #ifdef ALLOW_NON_PROFILED_LOGIN
  1047. else if ( controlID == buttonUseAccountID )
  1048. {
  1049. buttonPushed = true;
  1050. nextScreen = "Menus/GameSpyLoginProfile.wnd";
  1051. TheShell->pop();
  1052. //TheShell->push( "Menus/GameSpyLoginProfile.wnd" );
  1053. } //if ( controlID == buttonUseAccount )
  1054. else if ( controlID == buttonDontUseAccountID )
  1055. {
  1056. buttonPushed = true;
  1057. nextScreen = "Menus/GameSpyLoginQuick.wnd";
  1058. TheShell->pop();
  1059. //TheShell->push( "Menus/GameSpyLoginQuick.wnd" );
  1060. } //if ( controlID == buttonDontUseAccount )
  1061. #endif // ALLOW_NON_PROFILED_LOGIN
  1062. else if ( controlID == buttonCreateAccountID )
  1063. {
  1064. #ifdef ALLOW_NON_PROFILED_LOGIN
  1065. if (GameSpyUseProfiles)
  1066. {
  1067. #endif // ALLOW_NON_PROFILED_LOGIN
  1068. // actually attempt to create an account based on info entered
  1069. AsciiString month, day, year;
  1070. month.translate( GadgetTextEntryGetText(textEntryMonth) );
  1071. day.translate( GadgetTextEntryGetText(textEntryDay) );
  1072. year.translate( GadgetTextEntryGetText(textEntryYear) );
  1073. if(!isAgeOkay(month, day, year))
  1074. {
  1075. GSMessageBoxOk(TheGameText->fetch("GUI:AgeFailedTitle"), TheGameText->fetch("GUI:AgeFailed"));
  1076. break;
  1077. }
  1078. AsciiString login, password, email;
  1079. email.translate( GadgetComboBoxGetText(comboBoxEmail) );
  1080. login.translate( GadgetComboBoxGetText(comboBoxLoginName) );
  1081. password.translate( GadgetTextEntryGetText(textEntryPassword) );
  1082. if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() )
  1083. {
  1084. loginAttemptTime = timeGetTime();
  1085. BuddyRequest req;
  1086. req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGINNEW;
  1087. strcpy(req.arg.login.nick, login.str());
  1088. strcpy(req.arg.login.email, email.str());
  1089. strcpy(req.arg.login.password, password.str());
  1090. req.arg.login.hasFirewall = TRUE;
  1091. TheGameSpyInfo->setLocalBaseName( login );
  1092. //TheGameSpyInfo->setLocalProfileID( resp.player.profileID );
  1093. TheGameSpyInfo->setLocalEmail( email );
  1094. TheGameSpyInfo->setLocalPassword( password );
  1095. DEBUG_LOG(("before create: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str()));
  1096. TheGameSpyBuddyMessageQueue->addRequest( req );
  1097. if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword))
  1098. {
  1099. (*loginPref)["lastName"] = login;
  1100. (*loginPref)["lastEmail"] = email;
  1101. (*loginPref)["useProfiles"] = "yes";
  1102. AsciiString date;
  1103. date = month;
  1104. date.concat(day);
  1105. date.concat(year);
  1106. loginPref->addLogin(email, login, password, date);
  1107. }
  1108. EnableLoginControls( FALSE );
  1109. // fire off some pings
  1110. startPings();
  1111. }
  1112. else
  1113. {
  1114. // user didn't fill in all info. prompt him.
  1115. if(email.isEmpty() && login.isEmpty() && password.isEmpty())
  1116. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoAll"));
  1117. else if( email.isEmpty() && login.isEmpty())
  1118. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmailNickname"));
  1119. else if( email.isEmpty() && password.isEmpty())
  1120. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmailPassword"));
  1121. else if( login.isEmpty() && password.isEmpty())
  1122. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoNicknamePassword"));
  1123. else if( email.isEmpty())
  1124. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoEmail"));
  1125. else if( password.isEmpty())
  1126. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoPassword"));
  1127. else if( login.isEmpty() )
  1128. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoNickname"));
  1129. else
  1130. GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSNoLoginInfoAll"));
  1131. }
  1132. #ifdef ALLOW_NON_PROFILED_LOGIN
  1133. }
  1134. else
  1135. {
  1136. // not the profile screen - switch to it
  1137. buttonPushed = TRUE;
  1138. nextScreen = "Menus/GameSpyLoginProfile.wnd";
  1139. TheShell->pop();
  1140. }
  1141. #endif // ALLOW_NON_PROFILED_LOGIN
  1142. } //if ( controlID == buttonCreateAccount )
  1143. else if ( controlID == buttonLoginID )
  1144. {
  1145. AsciiString login, password, email;
  1146. #ifdef ALLOW_NON_PROFILED_LOGIN
  1147. if (GameSpyUseProfiles)
  1148. {
  1149. #endif // ALLOW_NON_PROFILED_LOGIN
  1150. AsciiString month, day, year;
  1151. month.translate( GadgetTextEntryGetText(textEntryMonth) );
  1152. day.translate( GadgetTextEntryGetText(textEntryDay) );
  1153. year.translate( GadgetTextEntryGetText(textEntryYear) );
  1154. if(!isAgeOkay(month, day, year))
  1155. {
  1156. GSMessageBoxOk(TheGameText->fetch("GUI:AgeFailedTitle"), TheGameText->fetch("GUI:AgeFailed"));
  1157. break;
  1158. }
  1159. email.translate( GadgetComboBoxGetText(comboBoxEmail) );
  1160. login.translate( GadgetComboBoxGetText(comboBoxLoginName) );
  1161. password.translate( GadgetTextEntryGetText(textEntryPassword) );
  1162. if ( !email.isEmpty() && !login.isEmpty() && !password.isEmpty() )
  1163. {
  1164. loginAttemptTime = timeGetTime();
  1165. BuddyRequest req;
  1166. req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGIN;
  1167. strcpy(req.arg.login.nick, login.str());
  1168. strcpy(req.arg.login.email, email.str());
  1169. strcpy(req.arg.login.password, password.str());
  1170. req.arg.login.hasFirewall = true;
  1171. TheGameSpyInfo->setLocalBaseName( login );
  1172. //TheGameSpyInfo->setLocalProfileID( resp.player.profileID );
  1173. TheGameSpyInfo->setLocalEmail( email );
  1174. TheGameSpyInfo->setLocalPassword( password );
  1175. DEBUG_LOG(("before login: TheGameSpyInfo->stuff(%s/%s/%s)\n", TheGameSpyInfo->getLocalBaseName().str(), TheGameSpyInfo->getLocalEmail().str(), TheGameSpyInfo->getLocalPassword().str()));
  1176. TheGameSpyBuddyMessageQueue->addRequest( req );
  1177. if(checkBoxRememberPassword && GadgetCheckBoxIsChecked(checkBoxRememberPassword))
  1178. {
  1179. (*loginPref)["lastName"] = login;
  1180. (*loginPref)["lastEmail"] = email;
  1181. (*loginPref)["useProfiles"] = "yes";
  1182. AsciiString date;
  1183. date = month;
  1184. date.concat(day);
  1185. date.concat(year);
  1186. loginPref->addLogin(email, login, password,date);
  1187. }
  1188. else
  1189. {
  1190. loginPref->forgetLogin(email);
  1191. }
  1192. EnableLoginControls( FALSE );
  1193. // fire off some pings
  1194. startPings();
  1195. }
  1196. else
  1197. {
  1198. // user didn't fill in all info. prompt him.
  1199. if(email.isEmpty() && login.isEmpty() && password.isEmpty())
  1200. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoAll"));
  1201. else if( email.isEmpty() && login.isEmpty())
  1202. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmailNickname"));
  1203. else if( email.isEmpty() && password.isEmpty())
  1204. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmailPassword"));
  1205. else if( login.isEmpty() && password.isEmpty())
  1206. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoNicknamePassword"));
  1207. else if( email.isEmpty())
  1208. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoEmail"));
  1209. else if( password.isEmpty())
  1210. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoPassword"));
  1211. else if( login.isEmpty() )
  1212. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoNickname"));
  1213. else
  1214. GSMessageBoxOk(TheGameText->fetch("GUI:GSErrorTitle"), TheGameText->fetch("GUI:GSNoLoginInfoAll"));
  1215. }
  1216. #ifdef ALLOW_NON_PROFILED_LOGIN
  1217. }
  1218. else
  1219. {
  1220. login.translate( GadgetTextEntryGetText(textEntryLoginName) );
  1221. if ( !login.isEmpty() )
  1222. {
  1223. loginAttemptTime = timeGetTime();
  1224. PeerRequest req;
  1225. req.peerRequestType = PeerRequest::PEERREQUEST_LOGIN;
  1226. req.nick = login.str();
  1227. req.login.profileID = 0;
  1228. TheGameSpyPeerMessageQueue->addRequest( req );
  1229. (*loginPref)["lastName"] = login;
  1230. loginPref->erase("lastEmail");
  1231. (*loginPref)["useProfiles"] = "no";
  1232. EnableLoginControls( FALSE );
  1233. // fire off some pings
  1234. startPings();
  1235. }
  1236. }
  1237. #endif // ALLOW_NON_PROFILED_LOGIN
  1238. } //if ( controlID == buttonLogin )
  1239. else if ( controlID == buttonTOSID )
  1240. {
  1241. parentTOS->winHide(FALSE);
  1242. useWebBrowserForTOS = FALSE;//loginPref->getBool("UseTOSBrowser", TRUE);
  1243. if (useWebBrowserForTOS && (TheWebBrowser != NULL))
  1244. {
  1245. TheWebBrowser->createBrowserWindow("TermsOfService", listboxTOS);
  1246. webBrowserActive = TRUE;
  1247. }
  1248. else
  1249. {
  1250. // Okay, no web browser. This means we're looking at a UTF-8 text file.
  1251. GadgetListBoxReset(listboxTOS);
  1252. AsciiString fileName;
  1253. fileName.format("Data\\%s\\TOS.txt", GetRegistryLanguage().str());
  1254. File *theFile = TheFileSystem->openFile(fileName.str(), File::READ);
  1255. if (theFile)
  1256. {
  1257. Int size = theFile->size();
  1258. char *fileBuf = new char[size];
  1259. Color tosColor = GameMakeColor(255, 255, 255, 255);
  1260. Int bytesRead = theFile->read(fileBuf, size);
  1261. if (bytesRead == size && size > 2)
  1262. {
  1263. fileBuf[size-1] = 0; // just to be safe
  1264. AsciiString asciiBuf = fileBuf+2;
  1265. AsciiString asciiLine;
  1266. while (asciiBuf.nextToken(&asciiLine, "\r\n"))
  1267. {
  1268. UnicodeString uniLine;
  1269. uniLine = UnicodeString(MultiByteToWideCharSingleLine(asciiLine.str()).c_str());
  1270. int len = uniLine.getLength();
  1271. for (int index = len-1; index >= 0; index--)
  1272. {
  1273. if (iswspace(uniLine.getCharAt(index)))
  1274. {
  1275. uniLine.removeLastChar();
  1276. }
  1277. else
  1278. {
  1279. break;
  1280. }
  1281. }
  1282. //uniLine.trim();
  1283. DEBUG_LOG(("adding TOS line: [%ls]\n", uniLine.str()));
  1284. GadgetListBoxAddEntryText(listboxTOS, uniLine, tosColor, -1);
  1285. }
  1286. }
  1287. delete fileBuf;
  1288. fileBuf = NULL;
  1289. theFile->close();
  1290. theFile = NULL;
  1291. }
  1292. }
  1293. EnableLoginControls( FALSE );
  1294. buttonBack->winEnable(FALSE);
  1295. }
  1296. else if ( controlID == buttonTOSOKID )
  1297. {
  1298. EnableLoginControls( TRUE );
  1299. parentTOS->winHide(TRUE);
  1300. if (useWebBrowserForTOS && (TheWebBrowser != NULL))
  1301. {
  1302. if (listboxTOS != NULL)
  1303. {
  1304. TheWebBrowser->closeBrowserWindow(listboxTOS);
  1305. }
  1306. }
  1307. OptionPreferences optionPref;
  1308. optionPref["SawTOS"] = "yes";
  1309. optionPref.write();
  1310. webBrowserActive = FALSE;
  1311. buttonBack->winEnable(TRUE);
  1312. }
  1313. break;
  1314. }// case GBM_SELECTED:
  1315. case GEM_EDIT_DONE:
  1316. {
  1317. break;
  1318. }
  1319. /*
  1320. case GEM_UPDATE_TEXT:
  1321. {
  1322. if (buttonPushed)
  1323. break;
  1324. GameWindow *control = (GameWindow *)mData1;
  1325. Int controlID = control->winGetWindowId();
  1326. if ( controlID == textEntryLoginNameID )
  1327. {
  1328. UnicodeString munkee = GadgetTextEntryGetText( textEntryLoginName );
  1329. if ( !isNickOkay( munkee ) )
  1330. {
  1331. munkee.removeLastChar();
  1332. GadgetTextEntrySetText( textEntryLoginName, munkee );
  1333. }
  1334. }// if ( controlID == textEntryLoginNameID )
  1335. break;
  1336. }//case GEM_UPDATE_TEXT:
  1337. */
  1338. default:
  1339. return MSG_IGNORED;
  1340. }//Switch
  1341. return MSG_HANDLED;
  1342. }// WOLLoginMenuSystem