wdgt-H5DA[;1.4CallWave, Inc.Copyright (c) 2007 CallWave, Inc.` @H off WIDGET_mainWindow CallWave SMS Widget 436 409 true 0 0 436 409 false 0 0 436 42 true 0 0 true 0 42 436 230 true 0 0 320 true 158 47 true 158 77 true 344 77 true 158 107 true 158 137 true 290 170 72 19 true 0 272 436 47 true 0 0 true 0 0 436 409 false 0 0 436 42 true 0 0 true 0 42 436 180 true 0 0 320 true 158 47 true 158 77 true 344 77 true 158 107 true 290 140 72 19 true 0 222 436 47 true 0 0 true 0 0 436 409 false 0 0 436 42 true 0 0 true 0 42 436 80 true 0 0 320 true 0 122 436 47 true 0 0 true 0 0 436 409 false 0 0 436 42 true 0 0 true 0 42 436 230 true 0 0 320 true 251 69 true 150 386 69 true 53 178 true 150 210 180 72 19 true 0 272 436 47 true 0 0 true 0 0 436 409 false 0 0 436 42 true 0 0 true 0 42 436 190 true 0 0 320 true 30 16 true 140 151 16 true 260 16 true 130 30 49 true 140 151 49 true 185 53 true 280 53 true 30 87 true 268 64 318 120 true 0 232 436 47 true 0 0 true 392 3 true true Account text true UString text true LastContact text true Mode text true SenderCarrierId text true SenderEmail text true SenderMobile text true text true text true text Down-rev Address Book contacts. true text Down-rev email address. true text Down-rev mobile phone number. true Down-rev service provider. popup sASAvP/****************************************************************************** SMS_AddressBook c'tor ******************************************************************************/ function SMS_AddressBook( contactNameTextArea, contactPhoneNumberTextArea, contactCarrierNameTextArea, onCarrierChangeRequired ) { try { var self = this; // Initialize member variables this.m_selectedContactId = this.INVALID_ENTRY_INDEX; this.m_contactNameTextArea = contactNameTextArea; this.m_contactPhoneNumberTextArea = contactPhoneNumberTextArea; this.m_contactCarrierNameTextArea = contactCarrierNameTextArea; this.m_showCarrierFormField = true; this.m_onCarrierChangeRequired = onCarrierChangeRequired; // Construct contact list from preferences string try { var addressBookString = VM_GetPreference( PREF_KEY_ADDRESS_BOOK ); if ( addressBookString !== null && typeof addressBookString != 'undefined' ) { this.m_contactList = eval( "new Array( " + addressBookString + " )" ); } else { // Try the down-rev address book addressBookString = VM_GetPreference( PREF_KEY_DOWNREV_ADDRESS_BOOK ); if ( addressBookString !== null && typeof addressBookString != 'undefined' ) { this.m_contactList = eval( "new Array( " + addressBookString + " )" ); // Migrate down-rev carrier strings to new carrier id this.migrateDownRevContacts( ); } } } catch ( e ) { EX_Log( "SMS_AddressBook::SMS_AddressBook( ) : Failed to load address book from preferences:\n" + e ); } if ( this.m_contactList == null ) { // We weren't able to load an address book. Construct as empty. this.m_contactList = new Array( ); } // Initialize name this.m_contactNameTextArea.data = this.DEFAULT_NAME; // Find the last selected contact var lastContactName = VM_GetPreference( PREF_KEY_LAST_CONTACT_KEY ); if ( lastContactName != null ) { var contactIndexOf = this.findContact( lastContactName ); if ( contactIndexOf == this.INVALID_ENTRY_INDEX ) { return; } this.onSelectionChanged( contactIndexOf ); } } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AddressBook::SMS_AddressBook( ) : " ); } } SMS_AddressBook.prototype = { INVALID_ENTRY_INDEX : -1, DEFAULT_NAME : "Name", /************************************************************************** ************************************************************************** Private methods *************************************************************************** **************************************************************************/ migrateDownRevContacts : function( ) { for ( var i = 0; i < this.m_contactList.length; i++ ) { if ( typeof this.m_contactList[i].carrier == 'undefined' ) { // Not a down-rev contact - no migration required. continue; } if ( isNaN( this.m_contactList[i].carrier ) ) { // Map carrier name string to carrier id this.m_contactList[i].carrierId = SMS_FindCarrierId( this.m_contactList[i].carrier ); } else { this.m_contactList[i].carrierId = this.m_contactList[i].carrier; } } }, contactNameSortPredicate : function( lhs , rhs ) { var lhsName = lhs.name.toLowerCase( ); var rhsName = rhs.name.toLowerCase( ); if ( lhsName < rhsName ) { return -1; } else if ( lhsName > rhsName ) { return 1; } return 0; }, addContact : function( newContact ) { this.m_contactList[this.m_contactList.length] = newContact; }, findContact : function( contactName ) { for ( var i = 0; i < this.m_contactList.length; ++i ) { if ( this.m_contactList[i].name == contactName ) { return i; } } return this.INVALID_ENTRY_INDEX; }, sort : function( ) { try { var self = this; this.m_contactList.sort( self.contactNameSortPredicate ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AddressBook::sort( )" ); } }, getArrayOfAddressBookNames : function( ) { var names = new Array( ); for ( var i = 0; i < this.m_contactList.length; ++i ) { names[i] = this.m_contactList[i].name; } return names; }, getArrayOfAddressBookIndices : function( ) { var indices = new Array( ); for ( var i = 0; i < this.m_contactList.length; ++i ) { indices[i] = i; } return indices; }, onAddToAddressBook : function( ) { try { var formfields = new Array( ); formfields[0] = new FormField( ); formfields[0].name = "contactName"; formfields[0].type = "text"; formfields[0].title = "Name:"; formfields[0].description = "Contact's name as you want it displayed in your address book."; formfields[1] = new FormField( ); formfields[1].name = "contactNumber"; formfields[1].type = "text"; formfields[1].title = "Mobile Number:"; formfields[1].description = "Contact's mobile number. A 10-digit USA/Canada number, or an International number including country code."; if ( this.m_showCarrierFormField == true ) { formfields[2] = new FormField( ); formfields[2].name = "contactCarrier"; formfields[2].type = "popup"; formfields[2].title = "Carrier:"; formfields[2].description = "Contact's mobile carrier. Not required for International carriers."; formfields[2].option = GetRecipientCarrierNames( ); formfields[2].optionValue = GetRecipientCarrierIds( ); } formResults = form( formfields, "Add Contact", "Add Contact", "Cancel" ); if ( formResults == null ) { return; } var newName = formResults[0]; var newNumber = formResults[1]; var newCarrierId = ( this.m_showCarrierFormField == true ) ? formResults[2] : INVALID_CARRIER_ID; if ( newName == "-" ) { // A contact name cannot consist of just a dash. Since the dash is a reserved character in // popup menus, this would result in the contact being displayed as a non-selectable menu separator. alert( "Contact not saved.\n\nInvalid contact name." ); return; } if ( newName == null || newName.length == 0 ) { alert( "Contact not saved.\n\nContact's name is required." ); return; } if ( this.findContact( newName ) != this.INVALID_ENTRY_INDEX ) { alert( "Contact not saved.\n\nA contact with the name '" + newName + "' already exists in your address book." ); return; } if ( newNumber == null || newNumber.length == 0 ) { alert( "Contact not saved.\n\nContact's mobile number is required." ); return; } // Perform a basic validation of the phone number var phoneNumber = new PHONE_PhoneNumber( newNumber ); if ( phoneNumber.m_trimmedNumber.length == 0 ) { alert( "Contact not saved.\n\nA valid contact mobile number is required." ); return; } if ( phoneNumber.m_countryCode == CMD_COUNTRY_CODE_NANP ) { if ( phoneNumber.m_nationalNumber.length != PHONE_NATIONAL_NUMBER_LENGTH ) { alert( "Contact not saved.\n\nUSA/Canada number must be exactly " + PHONE_NATIONAL_NUMBER_LENGTH + " digits." ); return; } } else if ( phoneNumber.m_trimmedNumber.length < PHONE_MIN_INTERNATIONAL_NUMBER_LENGTH ) { alert( "Contact not saved.\n\nUSA/Canada numbers must be exactly " + PHONE_NATIONAL_NUMBER_LENGTH + " digits. International numbers must be at least " + PHONE_MIN_INTERNATIONAL_NUMBER_LENGTH + " digits." ); return; } var newContactEntry = new Object( ); newContactEntry[ "name" ] = newName; newContactEntry[ "number" ] = phoneNumber.m_formattedNumber; newContactEntry[ "carrierId" ] = newCarrierId; this.addContact( newContactEntry ); this.sort( ); this.save( ); var contactIndexOf = this.findContact( newContactEntry.name ); if ( contactIndexOf >= 0 ) { this.onSelectionChanged( contactIndexOf ); } } catch ( e ) { EX_Log( "SMS_AddressBook::onAddToAddressBook( ) : " + e ); } }, onRemoveFromAddressBook : function( ) { try { var formfields = new Array( ); formfields[0] = new FormField( ); formfields[0].name = "contactName"; formfields[0].type = "popup"; formfields[0].title = "Contact:"; formfields[0].description = "Select the contact you want to delete from your address book."; formfields[0].option = this.getArrayOfAddressBookNames( ); formfields[0].optionValue = this.getArrayOfAddressBookIndices( ); formResults = form( formfields, "Delete Contact", "Delete Contact", "Cancel" ); if ( formResults == null ) { return; } var contactIndexOf = formResults[0]; this.m_contactList.splice( contactIndexOf, 1 ); this.save( ); if ( this.m_selectedContactId == contactIndexOf ) { this.m_contactNameTextArea.data = this.DEFAULT_NAME; this.m_contactPhoneNumberTextArea.data = ""; var carrierList = SMS_GetRecipientCarrierList( ); this.m_contactCarrierNameTextArea.data = carrierList[0][0]; } } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AddressBook::onRemoveFromAddressBook( )" ); } }, onSelectionChanged : function( newSelectionIndex ) { try { this.m_selectedContactId = newSelectionIndex; this.m_contactNameTextArea.data = this.m_contactList[this.m_selectedContactId].name; this.m_contactPhoneNumberTextArea.data = this.m_contactList[this.m_selectedContactId].number; var selectedContactCarrierId = INVALID_CARRIER_ID; var carrierList = SMS_GetRecipientCarrierList( ); for ( var i = 0; i < carrierList.length; ++i ) { if ( this.m_contactList[this.m_selectedContactId].carrierId == carrierList[i][1] ) { selectedContactCarrierId = carrierList[i][1]; break; } } this.m_contactNameTextArea.focus( ); this.m_contactNameTextArea.select( 0, -1 ); VM_SetPreference( PREF_KEY_LAST_CONTACT_KEY, this.m_contactNameTextArea.data ); this.m_onCarrierChangeRequired( selectedContactCarrierId ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AddressBook::onSelectionChanged( )" ); } }, /************************************************************************** ************************************************************************** Public methods *************************************************************************** **************************************************************************/ save : function( ) { try { var addressBookString = ''; for ( var i = 0; i < this.m_contactList.length; i++ ) { if ( i != 0 ) { addressBookString += ", "; } // Escape single-quote characters in the contact name and contact number var contactName = this.m_contactList[i].name; contactName = contactName.replace( /\'/g, "\\'" ); var contactNumber = this.m_contactList[i].number; contactNumber = contactNumber.replace( /\'/g, "\\'" ); addressBookString += "{'name':'" + contactName + "', "; addressBookString += "'number':'" + contactNumber + "', "; addressBookString += "'carrierId':'" + this.m_contactList[i].carrierId + "'}"; } VM_SetPreference( PREF_KEY_ADDRESS_BOOK, addressBookString ); savePreferences( ); } catch ( e ) { EX_Log( e, "SMS_AddressBook::save( )" ); } }, showCarriers : function( showCarriers ) { this.m_showCarrierFormField = showCarriers; }, resetNameSelection : function( ) { this.m_contactNameTextArea.data = this.DEFAULT_NAME; this.m_selectedContactId = this.INVALID_ENTRY_INDEX; }, showMenu : function( hOffset, vOffset ) { try { var popupMenuItems = new Array( ); popupMenuItems[0] = new MenuItem( ); popupMenuItems[0].title = "Add new contact..."; popupMenuItems[0].onSelect = "SMS_widgetViewController.GetSMSView( ).getAddressBook( ).onAddToAddressBook( );"; popupMenuItems[0].enabled = true; popupMenuItems[1] = new MenuItem( ); popupMenuItems[1].title = "Delete contact..."; popupMenuItems[1].onSelect = "SMS_widgetViewController.GetSMSView( ).getAddressBook( ).onRemoveFromAddressBook( );"; popupMenuItems[1].enabled = ( this.m_contactList.length > 0 ) ? true : false; popupMenuItems[2] = new MenuItem( ); popupMenuItems[2].title = "-------- Contacts ---------"; popupMenuItems[2].onSelect = ""; popupMenuItems[2].enabled = false; for ( var contactListIndex = 0; contactListIndex < this.m_contactList.length; ++contactListIndex ) { var newMenuItemIndex = popupMenuItems.length; popupMenuItems[newMenuItemIndex] = new MenuItem( ); popupMenuItems[newMenuItemIndex].title = this.m_contactList[contactListIndex].name; popupMenuItems[newMenuItemIndex].onSelect = "SMS_widgetViewController.GetSMSView( ).getAddressBook( ).onSelectionChanged( " + contactListIndex + " );"; popupMenuItems[newMenuItemIndex].enabled = true; if ( contactListIndex == this.m_selectedContactId ) { popupMenuItems[newMenuItemIndex].checked = true; } } popupMenu( popupMenuItems, hOffset, vOffset ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AddressBook::showMenu( )" ); } } } 6$c/****************************************************************************** Carrier name/value lists ******************************************************************************/ // Master set of carrier/provider id pairs var INVALID_CARRIER_ID = -100; var INTERNATIONAL_CARRIER_ID = -1; var OTHER_CARRIER_ID = 0; var CARRIER_SET = new Array( ); CARRIER_SET[CARRIER_SET.length] = ['- US Top Carriers --', INVALID_CARRIER_ID]; CARRIER_SET[CARRIER_SET.length] = ['Cingular', 4]; CARRIER_SET[CARRIER_SET.length] = ['Sprint', 11]; CARRIER_SET[CARRIER_SET.length] = ['Verizon', 12]; CARRIER_SET[CARRIER_SET.length] = ['- US All Carriers --', INVALID_CARRIER_ID]; CARRIER_SET[CARRIER_SET.length] = ['Alltel', 1]; CARRIER_SET[CARRIER_SET.length] = ['Bluegrass Cellular', 51]; CARRIER_SET[CARRIER_SET.length] = ['Cellcom', 24]; CARRIER_SET[CARRIER_SET.length] = ['Cellular One', 3]; CARRIER_SET[CARRIER_SET.length] = ['Cellular South', 58]; CARRIER_SET[CARRIER_SET.length] = ['Cincinnati Bell', 19]; CARRIER_SET[CARRIER_SET.length] = ['Cingular', 4]; CARRIER_SET[CARRIER_SET.length] = ['Cingular TDMA (old)', 2]; CARRIER_SET[CARRIER_SET.length] = ['Cricket', 20]; CARRIER_SET[CARRIER_SET.length] = ['Dobson Cellular', 59]; CARRIER_SET[CARRIER_SET.length] = ['First Cellular (IL)', 48]; CARRIER_SET[CARRIER_SET.length] = ['IL Valley Cellular', 29]; CARRIER_SET[CARRIER_SET.length] = ['Intercel', 47]; CARRIER_SET[CARRIER_SET.length] = ['Iowa Wireless', 28]; CARRIER_SET[CARRIER_SET.length] = ['Metro PCS', 23]; CARRIER_SET[CARRIER_SET.length] = ['Midwest Wireless', 31]; CARRIER_SET[CARRIER_SET.length] = ['Nextel', 7]; CARRIER_SET[CARRIER_SET.length] = ['Northcoast PCS', 26]; CARRIER_SET[CARRIER_SET.length] = ['NTELOS', 36]; CARRIER_SET[CARRIER_SET.length] = ['Southern Linc', 10]; CARRIER_SET[CARRIER_SET.length] = ['Sprint', 11]; CARRIER_SET[CARRIER_SET.length] = ['SunCom / Triton', 35]; CARRIER_SET[CARRIER_SET.length] = ['T-Mobile', 14]; CARRIER_SET[CARRIER_SET.length] = ['Unicel', 38]; CARRIER_SET[CARRIER_SET.length] = ['U.S. Cellular', 15]; CARRIER_SET[CARRIER_SET.length] = ['Verizon', 12]; CARRIER_SET[CARRIER_SET.length] = ['Western Wireless', 25]; CARRIER_SET[CARRIER_SET.length] = ['----- Canada ------', INVALID_CARRIER_ID]; CARRIER_SET[CARRIER_SET.length] = ['CA: Aliant', 61]; CARRIER_SET[CARRIER_SET.length] = ['CA: Bell Mobile', 62]; CARRIER_SET[CARRIER_SET.length] = ['CA: Fido', 63]; CARRIER_SET[CARRIER_SET.length] = ['CA: MTS', 64]; CARRIER_SET[CARRIER_SET.length] = ['CA: Rogers', 65]; CARRIER_SET[CARRIER_SET.length] = ['CA: SaskTel Mobile', 66]; CARRIER_SET[CARRIER_SET.length] = ['CA: TELUS Mobile', 67]; CARRIER_SET[CARRIER_SET.length] = ['CA: Virgin Mobile', 68]; CARRIER_SET[CARRIER_SET.length] = ['------------------', INVALID_CARRIER_ID]; CARRIER_SET[CARRIER_SET.length] = ['Other', OTHER_CARRIER_ID]; /****************************************************************************** GetRecipientCarrierNames ******************************************************************************/ function GetRecipientCarrierNames( ) { if ( typeof RECIPIENT_CARRIER_NAMES == 'undefined' ) { RECIPIENT_CARRIER_NAMES = new Array( ); var recipientCarrierList = SMS_GetRecipientCarrierList( ); var n; for ( n = 0; n < recipientCarrierList.length; ++n ) { RECIPIENT_CARRIER_NAMES[RECIPIENT_CARRIER_NAMES.length] = recipientCarrierList[n][0]; } } return RECIPIENT_CARRIER_NAMES; } /****************************************************************************** GetRecipientCarrierIds ******************************************************************************/ function GetRecipientCarrierIds( ) { if ( typeof RECIPIENT_CARRIER_IDS == 'undefined' ) { RECIPIENT_CARRIER_IDS = new Array( ); var recipientCarrierList = SMS_GetRecipientCarrierList( ); var n; for ( n = 0; n < recipientCarrierList.length; ++n ) { RECIPIENT_CARRIER_IDS[RECIPIENT_CARRIER_IDS.length] = recipientCarrierList[n][1]; } } return RECIPIENT_CARRIER_IDS; }  0lvPPNG  IHDR!^gAMAOX2tEXtSoftwareAdobe ImageReadyqe<IDATxˎ5]sK;$lPAX (b{ !6Q ec D6"HK߫OM;=iz_tOV_cWu9g6UUގDt$҉H",ҫ1AAݞ?"%_4i.JFuqk\ɒOnG;6ACHkI>Ve[hM F6[j/Oag)n?tLW\Զkg]cdh_pO}]te5MpY8[9Zq?2_)-k=zƷvl'[VfqmP]$9u?|:G,)whө0bZ[̓y" ]' ʕ/{ 5^n'0- r1fV, RW;m]oJ^xU1'P^_9b.rbL(1ȍmW]ƪضvչbsYAwIY穹\Ph 䳅|BPH qB(WHeCLH7'Tv6 ]m|nj ƶoJBc#%+_x4C}Ͷ]h̹Ͻquk;vvAxSC1fkϘs^hw,_RλyuV=@}B1r#6{ry1޳Ko6)ܕא{b={sW*އچ!o99C!cW;Rc$򧶋j+^hƓ7sFC .ۏ ?Dr)б1/  {I 9?S2nROw>ݡ2&s Ԑ|~1T;)MΡ,r.94аt AD- YM.θ?錻4 zSGl NK +9qkԗAQP{Ȥc$ %u`F gF(A٥4AAA5 8s%j9@k4ֿ4Gkj  A hN@yg+w®DJ[A7 8 8"6Ŗ,/-Ck5{O #Y.+ AAjI>! Ɠ̾6(mӁF&׆Hv}BTCnG?'r)?C])k% n?$K暗\c/Nс1%}&պp*TLnA1h-a}H`w9n2 M1'Zyj*#NԱHW[Z{a pGrGA~M7[y330|d_L>JXzeA}]wn$w*̹&9F5A0kg_2inÌS hOҖKMjPS`"ߓvֈΘ}xb*V1K#wftE!ȀڱL'eHndq8rLG\LЀ6e94fh>m_/ M4AvՍ0V@;Iyhc m߿В]ֽgC%tq&hAh&Vl|LjAC?fCfk+3aAfBZd%[k̄`At9f; xK #G 5+ 0y"i R.IENDB` RocPNG  IHDR?'1ՒgAMAOX2tEXtSoftwareAdobe ImageReadyqe<|IDATxڤXKr htvrTg=i+6O|\X>$ە9=>(-9} y|_fH[h b(؈ ǷHtMGPmwd6Gk*-g݉1{zIWzA)y\donT@lݪ3MRu\mm8ͣѷ]gr]Y\m^/ͰiJ Q/<r[*  IENDB` iplPNG  IHDR]gAMAOX2tEXtSoftwareAdobe ImageReadyqe<{IDATx ^4[48˽.C|M ?A#3;[?(نF9&©ͱ y@<  xx@<K0~6)ZݟgIENDB`gG>soPNG  IHDRHMsRGBgAMA a cHRMz&u0`:pQ<IDATx^ @EAH t̠߱dC~s!@`&IZ7-%w@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KZr-5Vh h8Z!%7@RhF@KKGPn EIENDB`-tpPNG  IHDRD[4gAMAOX2tEXtSoftwareAdobe ImageReadyqe<aIDATxb?> XXD-spp`pttd`Q0 Hg8pCSSSA@ o`]Y,mdIENDB`iv>sPNG  IHDRHgAMAOX2tEXtSoftwareAdobe ImageReadyqe<IDATxUnAY9m$CRXBi""RDiG-rAA)vg=v:iu{wo̼Cf5_M%{RoE&[ϊ uP"@9y&V ;D?nic&+`@jB2U HACH 2Lu ;gD&>p(Uh sCz/dbzL:DD.N?/}>_u?5On'2z*Qt0o>F-ɀR(9ՠ&\RAtzhȦegGj($p(3UiMԲƠ_n?D:1Ȯeo@_np=4ViwrfR}v>Z}dF[Q`S"ϘIENDB`(w-tPNG  IHDR;mGtIME  2 pHYs  ~IDATxc?b!WLt3mȿ4#n, UalŠs #NE(ƅ^:n|P X2F&~>0^`cm4@>ro5䲱~x aᕋbdb4Q(IENDB` yvPNG  IHDR;mGtIME  5w" pHYs  ~mIDATxc/@1`! @ ĜP@ _+fu ^fX 5@܇,Ȅ(0^ l Hmۛf {@ 0LfbbolUalUl0Cԑf0pj3ᰆ6;#.QfL?.lkt} L|`qِ@]}+.C!౶ӿa\. rz90@ Lf~/G1 F7$ 0"od$bQ(eDz_m<'cD.%mGC@e .]Nl__uݡu_ϸVӺ׍3*6]W3xX{P߿;Y<ҽhN˨h**EwؑQVڴd7#n/Y^R *[|r@)DBXy͍7NԨZIENDB` r{PNG  IHDRLEytIME#R pHYs  ~IDATxkTGǿ#MdWEcRQL-jEPQ5}>AA_/H־`)ԂRT|P j a1_w{ٻy;9g&AHIȉ)%uHo>'uNttv $YKˉK Swm--UEc3.e@~%+ttZwU7џwaU{ PF0SR)wu;zkLLxM֕+]Mդa@uC2cc, *C-sϨk)Kʹi/# &XH_]4 Je5I=3aSˌ-nҠ @W^h6莌v $sq*D.Dd Na} ޸ޠԶ!c?>zԃa{ ܒ]P2 %kj˛FyX,q&th;fR)NP?lv%Mב:doEhA:gKd\4n܈=t*\W/1zRt/e H?~WgΨHMѱs1RR299(` !%ͩ<J<{g>71ӃQҗց8ގ}FH\={6^PQ[nmE޽{,gܙ٩`PMνᒠSolZ=`b+'ԕ+Ђ V5k0tFU;}i W$Pd ׬Qײ:npcǔ Z$[I[-!zuMգN:<~ |I5r="J5_F͖5j-C֭_^ե<ݶMxZ55yF՛@quц ˗ս/ͽ&['$ᤅsnuO^з_FsUܾ%+x3JF/ŀ‹7vmm#Ү߳2J'aۘv۸ܶ 3 ]y'O*X '2m?H =R?~km9 pdBX[Ruh}'N(:{'F"RRa)xv/)` ^@~@u& g&go>SG<>ӞvQYp떪5y$Ts$/S\cL >ۙbr%Q`u7a- r~! )J@GH`a; OV7s+7ˆʒPIdG.e@gdHAS_P ,)9Kl7EdtŃ69XHU mPx=1Lfwd%0=*=MzB5W+Nb?VڟۊC>olB\-a?`|?@sġk;IENDB`]~PNG  IHDRLEytIMEw r pHYs  ~AIDATxYMhTW̛d&?mZb+B E*ąR ".4F0n Q]E#.XKhiML;d~N>c-19={眹ư, ,O>Hgx{1K?x1ZG~d>gsx+T{.~sw*U&aMM@8u+|k|ƍx'(U2dܜ׾Z[%aBjl׾䦈Ee2G6mBxQdY͎}r$]̌+Շ\k$bXl-nc8 7wan5'O"{.)y@l\ѣ0q?OVU ^PKyo|Gh+DŽo3lnpPLPGaBm޸\*%BR*kݲe!ӊ}Ϝ:^ 67۶:>D6o^Ɔwn ڵe݋hwNo:9)zOM<~ug/۷M7o܏ah+]fԻcczݽn0Guӽ_!#k):(B]*XNoe#Lg6%}Ź7uÅ=$ݖ?ߒUoʻQ!DT+$d a?{^;w9zF!ل:Jy_AnȑRxhTJTfFU IJ6 j@OJ!U̟9&0|IENDB`PNG  IHDR*/gAMAOX2tEXtSoftwareAdobe ImageReadyqe<,IDATx p\egͣIgOPAZAб (#Z((Uթ(>8:-hE_-6}&I$mӤk]6w7w(鐤?sgw{ݻw|wX,Fn,T*JiJ-iڟk%JRIh8f<:'uT*J5va|tN:#hnyj*JuL4tmoh@kOǣT*J561?l`;U 1c2r:4J~㘜p3Nj4'̌rB,1Ps:5JRM9YcNӱԆ TftLfLX:o%/LסT*j- -[^zr[T 9LNO2Ԭ!C\` {\PQ^b╥E˳=>O&o Dx|ѨZ4J֌<YyŊu2gڣ=ц6m|e#;lkUnw$XA3/YFPwbЙBTeLBK7771/NUUzeT*IDˡCt4?jPiviCqhe*|)9exeW=#9|ʻ>%%T*j͸"𢱮jH}Ouv Sشash5@R>ᨕMEf [+hܢE%+-i(X^.ɮ7ޠVԫDRFbFF ax !׆ڠǣ h42ȺϚIٙ8+V$,,3z5=88s*cTyOΝzT*(nT{!|z4zashn.-F+ a^in׃N/%Ky>TRzPּyTr.47Ɏ32(ՕHxCsΡwSÑj{5w8^f~۔{TҫBR yAǃ<9|6ؗ'Q)͔/Z ljwxaϫtc&\sF5Cz?C>rD*ՙ2nǿ]uYdyzog۾{75?4"ʚ3etlO| ee4~2dضW^q=ҏ~TnCs9_}^VJ8秾2 5p#zlHSqhN)~0EcP 7byE>7Of&y*֭=DyPyɤ"! Å&ǟ;y=ǏcVTf' z4n>Ai_$)sL@Qcq<ߟx=fڤN~|0}i^ʥ%*-CB 6yA1>X˜5B]N?.LcOt74P,g4Pۏ<ɰ"'C \׍8A'_~9i@ѯf&ov6u'i+שǗsnlNx1#=koܿFԸDG#9Gg1~Hi c8S'*X~`b1j`߶/7&}󽎊O?Pm#|.eZY&2f[_N syT%Tj |(;%VY#mW СC9c (V/@6L š[hI? *fB~VqGR*_\&DbCt:(2tIb`@w)E _*Ȝ6M(j7J9$Mפzif~?PgP?Nyv_d:~=~#E\pad!-mF%7LW]!Q]W9 A;*@桭ü *y=ze>[n"8 2mJLc  c6I;"G6 s3Wmm`4@Kևv'ơE\TS 72v5gB YV䦮jsVjoA=pN`Gx/yQ&R_,nD$0)Y}<eq^3)v'e˗ :_]%"0$.R/ʰf8ޢ|Xgr0{f-|608q3sR!EQT) fn~~webPa=lsі-T!Eay_Bڅ͛%혚q B;5_*p{6#۫;07=DCu86 '۩-; ].Q=@gyT\V%NE ) 4C!.ڇ 8]z\x[q[D0;KM1GrU6'C?q~_R`GR% N }Th0 _ A12W' 8"Hs?\22HKt$l~Y@/᪂SRwH@t#ʵwhoJ 7tXl@Di4Qq.%7$2c tp/LCjtRle.܅ t'mKϭ"hSt5bl .&sC}|Ls|)KÀ5B#*}@{w+;ӟa{E ٲ%<[~T*U@&"]\t>(-!8 m.+en?}ɘ _;XȸnČT5q@˦poh |Gf8/5@a\&gcB`&|7>A#Q@K.p6)>љys~y(wHWϋ YbYv^y7U%CM>K3cYǗ8WMe'\l0{N훜[ߛJJBcҔpq~;F3ˢ}nڈW 47Cob^ L)1OJ<?7 /Osp~Z9svnt(vg*[Ra%N,/癜8@ 3^~Y s|֭!q|ʹa k`u?Lb[(9d7)9GiJ:}/G**Mk%1صRn/ t$@ܵ+2\ֳ23g>]Fc=\*4hSaȡ,@ B)ƛjf}UO'&~喺DnƦU^-EHINFțyO<`NnNx8=RSp86/1q|gs'f|>(lj4 ;tǩ JWFDs8EU s8Թo_iG@n }˖zF w`vՀr@_XK+< SY nRH9kɿE;DxuD>" ] "d` 8%$fXJQI0hTT_ PC҅Md';+%pt#R&tEj Ő~rqK6uoily1(H K˭4T` |>v+Îeap2R~P*JzkvR&fV>C ڇN;KRT D)/|)@7ls%*JR EӹqSE7 ̪vX0ST*phraz'?)eG^T*J51SfT*J5bOzGO]3CyisJ:NƈZYA1 ?VjlRRTg6-S?|a Ӭ:s*JՂ3밹6ZYCD - 2h*Jh!1;8GFC }IRTo/BIENDB`]<=<t]/****************************************************************************** Dependencies: Shared/Extensions/Object.js Shared/XML/XML.js Shared/XML/Exceptions.js Shared/Http/HTTP.js Shared/Http/URL.js Shared/Messages/Exceptions.js Shared/Messages/RequestMessages.js Shared/Messages/ResponseMessages.js ******************************************************************************/ /****************************************************************************** ACC_ActivationHandler C'tor Parameters: [in] source [in] version [in] os ******************************************************************************/ function ACC_AccountHandler( source, version, os ) { this.m_source = source; this.m_version = version; this.m_os = os; this.m_onRegisterAccountSucceeded = null; this.m_onRegisterAccountFailed = null; this.m_onGetAccountInfoSucceeded = null; this.m_onGetAccountInfoFailed = null; this.m_onAuthenticateSucceeded = null; this.m_onAuthenticateFailed = null; this.m_onForgotPinSucceeded = null; this.m_onForgotPinFailed = null; // HTTP client for RegisterAccount messages var self = this; this.m_registerAccountHttpClient = new HttpClient( ); this.m_registerAccountHttpClient.onError = function( errorMessage ) { self.handleRegisterAccountError( errorMessage ); }; this.m_registerAccountHttpClient.onSuccess = function( xmlResponse ) { self.handleRegisterAccountResponse( xmlResponse ); }; // HTTP client for GetAccountInfo messages this.m_getAccountInfoHttpClient = new HttpClient( ); this.m_getAccountInfoHttpClient.onError = function( errorMessage ) { self.handleGetAccountInfoError( errorMessage ); }; this.m_getAccountInfoHttpClient.onSuccess = function( xmlResponse ) { self.handleGetAccountInfoResponse( xmlResponse ); }; // HTTP client for Authenticate messages this.m_authenticateHttpClient = new HttpClient( ); this.m_authenticateHttpClient.onError = function( errorMessage ) { self.handleAuthenticateError( errorMessage ); }; this.m_authenticateHttpClient.onSuccess = function( xmlResponse ) { self.handleAuthenticateResponse( xmlResponse ); }; // HTTP client for ForgotPin messages this.m_forgotPinHttpClient = new HttpClient( ); this.m_forgotPinHttpClient.onError = function( errorMessage ) { self.handleForgotPinError( errorMessage ); }; this.m_forgotPinHttpClient.onSuccess = function( xmlResponse ) { self.handleForgotPinResponse( xmlResponse ); }; } ACC_AccountHandler.prototype = { IsAuthenticationRequestInProgress : function( ) { try { return this.m_authenticateHttpClient.IsRequestInProgress( ) || this.m_forgotPinHttpClient.IsRequestInProgress( ) || this.m_getAccountInfoHttpClient.IsRequestInProgress( ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "ACC_AccountHandler::IsAuthenticationRequestInProgress( )" ); } }, IsRegistrationRequestInProgress : function( ) { try { return this.m_registerAccountHttpClient.IsRequestInProgress( ) || this.m_getAccountInfoHttpClient.IsRequestInProgress( ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "ACC_AccountHandler::IsRegistrationRequestInProgress( )" ); } }, StopAuthenticationRequests : function( ) { try { this.m_authenticateHttpClient.reset( ) } catch ( e ) { EX_Log( "ACC_AccountHandler::StopAuthenticationRequests( ) - stopping authenticate request\n" + e.message ); } try { this.m_forgotPinHttpClient.reset( ); } catch ( e ) { EX_Log( "ACC_AccountHandler::StopAuthenticationRequests( ) - stopping forgot pin request\n" + e.message ); } this.StopGetAccountInfoRequest( ); }, StopGetAccountInfoRequest : function( ) { try { this.m_getAccountInfoHttpClient.reset( ); } catch ( e ) { EX_Log( "ACC_AccountHandler::StopGetAccountInfoRequest( )\n" + e.message ); } }, StopRegistrationRequests : function( ) { try { this.m_registerAccountHttpClient.reset( ); } catch ( e ) { EX_Log( "ACC_AccountHandler::StopRegistrationRequests( )\n" + e.message ); } this.StopGetAccountInfoRequest( ); }, StopAllRequests : function( ) { try { this.StopRegistrationRequests( ); this.StopAuthenticationRequests( ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "ACC_AccountHandler::StopAllRequests( )" ); } }, /************************************************************************** Invoke callback functions **************************************************************************/ // RegisterAccount invokeOnRegisterAccountSucceededCallback:function( responseMessage ) { if ( this.m_onRegisterAccountSucceeded != null ) { this.m_onRegisterAccountSucceeded( responseMessage ); } }, invokeOnRegisterAccountFailedCallback:function( statusMessage ) { if ( this.m_onRegisterAccountFailed != null ) { this.m_onRegisterAccountFailed( statusMessage ); } }, // GetAccountInfo invokeOnGetAccountInfoSucceededCallback:function( responseMessage ) { if ( this.m_onGetAccountInfoSucceeded != null ) { this.m_onGetAccountInfoSucceeded( responseMessage ); } }, invokeOnGetAccountInfoFailedCallback:function( statusMessage ) { if ( this.m_onGetAccountInfoFailed != null ) { this.m_onGetAccountInfoFailed( statusMessage ); } }, // Authenticate invokeOnAuthenticateSucceededCallback:function( responseMessage ) { if ( this.m_onAuthenticateSucceeded != null ) { this.m_onAuthenticateSucceeded( responseMessage ); } }, invokeOnAuthenticateFailedCallback:function( statusMessage ) { if ( this.m_onAuthenticateFailed != null ) { this.m_onAuthenticateFailed( statusMessage ); } }, // ForgotPin invokeOnForgotPinSucceededCallback:function( responseMessage ) { if ( this.m_onForgotPinSucceeded != null ) { this.m_onForgotPinSucceeded( responseMessage ); } }, invokeOnForgotPinFailedCallback:function( statusMessage ) { if ( this.m_onForgotPinFailed != null ) { this.m_onForgotPinFailed( statusMessage ); } }, /************************************************************************** RegisterAccount methods **************************************************************************/ registerAccount:function( phoneNumber, pin, emailAddress ) { try { var requestMessage = new MSG_RegisterAccountRequest( this.m_source, this.m_version, this.m_os, phoneNumber, pin, emailAddress ); this.m_registerAccountHttpClient.sendRequest( HTTP_VERB_POST, ( VM_WIDGET_SOURCE != 'SG' && VM_WIDGET_SOURCE != 'VG' ) ? VM_URL.WSS1 : VM_URL.WS1, ( VM_WIDGET_SOURCE != 'SG' && VM_WIDGET_SOURCE != 'VG' ) ? VM_URL.WSS2 : VM_URL.WS2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { this.invokeOnRegisterAccountFailedCallback( "ACC_AccountHandler::registerAccount( ) : Failed to send RegisterAccount message :\n" + e.message ); } }, handleRegisterAccountResponse:function( xmlResponse ) { try { var responseMessage = new MSG_RegisterAccountResponse( xmlResponse ); this.invokeOnRegisterAccountSucceededCallback( responseMessage ); } catch ( e ) { // Failed to parse/process the response this.invokeOnRegisterAccountFailedCallback( "ACC_AccountHandler::handleRegisterAccountResponse( ) : Failed to process RegisterAccount response :\n" + e.message ); } }, handleRegisterAccountError:function( errorMessage ) { this.invokeOnRegisterAccountFailedCallback( errorMessage ); }, /************************************************************************** GetAccountInfo methods **************************************************************************/ getAccountInfo:function( accountNumber, uString ) { try { var requestMessage = new MSG_GetAccountInfoRequest( this.m_source, this.m_version, this.m_os, accountNumber, uString ); this.m_getAccountInfoHttpClient.sendRequest( HTTP_VERB_POST, VM_URL.WX1, VM_URL.WX2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { this.invokeOnGetAccountInfoFailedCallback( "ACC_AccountHandler::getAccountInfo( ) : Failed to send GetAccountInfo message :\n" + e.message ); } }, handleGetAccountInfoResponse:function( xmlResponse ) { try { var responseMessage = new MSG_GetAccountInfoResponse( xmlResponse ); this.invokeOnGetAccountInfoSucceededCallback( responseMessage ); } catch ( e ) { // Failed to parse/process the response this.invokeOnGetAccountInfoFailedCallback( "ACC_AccountHandler::handleGetAccountInfoResponse( ) : Failed to process GetAccountInfo response :\n" + e.message ); } }, handleGetAccountInfoError:function( errorMessage ) { this.invokeOnGetAccountInfoFailedCallback( errorMessage ); }, /************************************************************************** authenticate methods **************************************************************************/ authenticate:function( phoneNumber, pin ) { try { var requestMessage = new MSG_AuthenticateRequest( this.m_source, this.m_version, this.m_os, phoneNumber, pin ); this.m_authenticateHttpClient.sendRequest( HTTP_VERB_POST, VM_URL.WX1, VM_URL.WX2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { this.invokeOnAuthenticateFailedCallback( "ACC_AccountHandler::authenticate( ) : Failed to send Authenticate message :\n" + e.message ); } }, handleAuthenticateResponse:function( xmlResponse ) { try { var responseMessage = new MSG_AuthenticateResponse( xmlResponse ); this.invokeOnAuthenticateSucceededCallback( responseMessage ); } catch ( e ) { // Failed to parse/process the response this.invokeOnAuthenticateFailedCallback( "ACC_AccountHandler::handleAuthenticateResponse( ) : Failed to process Authenticate response :\n" + e.message ); } }, handleAuthenticateError:function( errorMessage ) { this.invokeOnAuthenticateFailedCallback( errorMessage ); }, /************************************************************************** ForgotPin methods **************************************************************************/ forgotPin:function( phoneNumber ) { try { var requestMessage = new MSG_ForgotPinRequest( this.m_source, this.m_version, this.m_os, phoneNumber ); this.m_forgotPinHttpClient.sendRequest( HTTP_VERB_POST, VM_URL.WS1, VM_URL.WS2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { this.invokeOnForgotPinFailedCallback( "ACC_AccountHandler::forgotPin( ) : Failed to send ForgotPin message :\n" + e.message ); } }, handleForgotPinResponse:function( xmlResponse ) { try { var responseMessage = new MSG_ForgotPinResponse( xmlResponse ); this.invokeOnForgotPinSucceededCallback( responseMessage ); } catch ( e ) { // Failed to parse/process the response this.invokeOnForgotPinFailedCallback( "ACC_AccountHandler::handleForgotPinResponse( ) : Failed to process ForgotPin response:\n" + e.message ); } }, handleForgotPinError:function( errorMessage ) { this.invokeOnForgotPinFailedCallback( errorMessage ); } }; ##/****************************************************************************** Dependencies: Shared/Extensions/Object.js Shared/XML/XML.js Shared/XML/Exceptions.js Shared/Http/HTTP.js Shared/Http/URL.js Shared/Messages/Exceptions.js Shared/Messages/RequestMessages.js Shared/Messages/ResponseMessages.js ******************************************************************************/ /****************************************************************************** ACT_ActivationHandler C'tor Parameters: [in] source [in] version [in] os [in] setCarrierInfoSucceededCallback [in] setCarrierInfoFailedCallback [in] verifyPhoneSucceededCallback [in] verifyPhoneFailedCallback ******************************************************************************/ function ACT_ActivationHandler( source, version, os, setCarrierInfoSucceededCallback, setCarrierInfoFailedCallback, verifyPhoneSucceededCallback, verifyPhoneFailedCallback ) { this.m_source = source; this.m_version = version; this.m_os = os; this.m_onSetCarrierInfoSucceeded = setCarrierInfoSucceededCallback; this.m_onSetCarrierInfoFailed = setCarrierInfoFailedCallback; this.m_onVerifyPhoneSucceeded = verifyPhoneSucceededCallback; this.m_onVerifyPhoneFailed = verifyPhoneFailedCallback; var self = this; // HTTP client for SetCarrierInfo messages this.m_setCarrierInfoHttpClient = new HttpClient( ); this.m_setCarrierInfoHttpClient.onError = function( errorMessage ) { self.handleSetCarrierInfoError( errorMessage ); }; this.m_setCarrierInfoHttpClient.onSuccess = function( xmlResponse ) { self.handleSetCarrierInfoResponse( xmlResponse ); }; // HTTP client for VerifyPhone messages this.m_verifyPhoneHttpClient = new HttpClient( ); this.m_verifyPhoneHttpClient.onError = function( errorMessage ) { self.handleVerifyPhoneError( errorMessage ); }; this.m_verifyPhoneHttpClient.onSuccess = function( xmlResponse ) { self.handleVerifyPhoneResponse( xmlResponse ); }; } ACT_ActivationHandler.prototype = { StopAllRequests : function( ) { try { try { this.m_setCarrierInfoHttpClient.reset( ); } catch ( e ) { EX_Log( "ACT_ActivationHandler::StopAllRequests( ) - stopping set carrier info request:\n" + e.message ); } try { this.m_verifyPhoneHttpClient.reset( ); } catch ( e ) { EX_Log( "ACT_ActivationHandler::StopAllRequests( ) - stopping verify phone request:\n" + e.message ); } } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "ACT_ActivationHandler::StopAllRequests( )" ); } }, IsSetCarrierInfoRequestInProgress : function( ) { try { return this.m_setCarrierInfoHttpClient.IsRequestInProgress( ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "ACT_ActivationHandler::IsSetCarrierInfoRequestInProgress( )" ); } }, IsVerifyPhoneRequestInProgress : function( ) { try { return this.m_verifyPhoneHttpClient.IsRequestInProgress( ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "ACT_ActivationHandler::IsVerifyPhoneRequestInProgress( )" ); } }, /************************************************************************** Invoke callback functions **************************************************************************/ invokeOnSetCarrierInfoSucceededCallback:function( responseMessage ) { this.m_onSetCarrierInfoSucceeded( responseMessage ); }, invokeOnSetCarrierInfoFailedCallback:function( statusMessage ) { this.m_onSetCarrierInfoFailed( statusMessage ); }, invokeOnVerifyPhoneSucceededCallback:function( responseMessage ) { this.m_onVerifyPhoneSucceeded( responseMessage ); }, invokeOnVerifyPhoneFailedCallback:function( statusMessage ) { this.m_onVerifyPhoneFailed( statusMessage ); }, /************************************************************************** SetCarrierInfo methods **************************************************************************/ setCarrierInfo:function( accountNumber, uString, carrierId ) { try { var requestMessage = new MSG_SetCarrierInfoRequest( this.m_source, this.m_version, this.m_os, accountNumber, uString, carrierId ); this.m_setCarrierInfoHttpClient.sendRequest( HTTP_VERB_POST, VM_URL.WS1, VM_URL.WS2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { this.invokeOnSetCarrierInfoFailedCallback( "Failed to send SetCarrierInfo message" ); } }, handleSetCarrierInfoResponse:function( xmlResponse ) { try { var responseMessage = new MSG_SetCarrierInfoResponse( xmlResponse ); this.invokeOnSetCarrierInfoSucceededCallback( responseMessage ); } catch ( e ) { // Failed to parse/process the response this.invokeOnSetCarrierInfoFailedCallback( "Failed to process SetCarrierInfo response" ); } }, handleSetCarrierInfoError:function( errorMessage ) { this.invokeOnSetCarrierInfoFailedCallback( errorMessage ); }, /************************************************************************** VerifyPhone methods **************************************************************************/ verifyPhone:function( accountNumber, uString, verificationCode, phoneCC, phoneNN ) { try { var requestMessage = new MSG_VerifyPhoneRequest( this.m_source, this.m_version, this.m_os, accountNumber, uString, verificationCode, phoneCC, phoneNN ); this.m_verifyPhoneHttpClient.sendRequest( HTTP_VERB_POST, VM_URL.WS1, VM_URL.WS2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { EX_Log( "ACT_ActivationHandler::verifyPhone( )\n" + e.message ); this.invokeOnVerifyPhoneFailedCallback( "Failed to send VerifyPhone message" ); } }, handleVerifyPhoneResponse:function( xmlResponse ) { try { var responseMessage = new MSG_VerifyPhoneResponse( xmlResponse ); this.invokeOnVerifyPhoneSucceededCallback( responseMessage ); } catch ( e ) { EX_Log( "ACT_ActivationHandler::handleVerifyPhoneResponse( )\n" + e.message ); this.invokeOnVerifyPhoneFailedCallback( "Failed to process VerifyPhone response" ); } }, handleVerifyPhoneError:function( errorMessage ) { try { this.invokeOnVerifyPhoneFailedCallback( errorMessage ); } catch ( e ) { EX_Log( "ACT_ActivationHandler::handleVerifyPhoneError( )\n" + e.message ); } } } 'BDt/****************************************************************************** Dependencies: Shared/Extensions/Object.js Shared/XML/XML.js Shared/XML/Exceptions.js Shared/Http/HTTP.js Shared/Http/URL.js Shared/Messages/Exceptions.js Shared/Messages/RequestMessages.js Shared/Messages/ResponseMessages.js ******************************************************************************/ /****************************************************************************** SMS_SMSHandler C'tor Parameters: [in] source [in] version [in] os [in] sendSMSucceededCallback [in] sendSMSFailedCallback ******************************************************************************/ function SMS_SMSHandler( source, version, os, sendSMSucceededCallback, sendSMSFailedCallback ) { this.m_source = source; this.m_version = version; this.m_os = os; this.m_onSendSMSSucceeded = sendSMSucceededCallback; this.m_onSendSMSFailed = sendSMSFailedCallback; var self = this; // HTTP client for SendSMS messages this.m_sendSMSHttpClient = new HttpClient( ); this.m_sendSMSHttpClient.onError = function( errorMessage ) { self.handleSendSMSError( errorMessage ); }; this.m_sendSMSHttpClient.onSuccess = function( xmlResponse ) { self.handleSendSMSResponse( xmlResponse ); }; } SMS_SMSHandler.prototype = { IsRequestInProgress: function( ) { return this.m_sendSMSHttpClient.IsRequestInProgress( ); }, /************************************************************************** Invoke callback functions **************************************************************************/ invokeOnSendSMSSucceededCallback:function( responseMessage ) { this.m_onSendSMSSucceeded( responseMessage ); }, invokeOnSendSMSFailedCallback:function( statusMessage ) { this.m_onSendSMSFailed( statusMessage ); }, /************************************************************************** SendSMS methods **************************************************************************/ sendSMS:function( accountNumber, uString, sendToPhoneNumber, sendToCarrierID, sendFromPreference, message ) { try { var requestMessage = new MSG_SendSMSRequest( this.m_source, this.m_version, this.m_os, accountNumber, uString, sendToPhoneNumber, sendToCarrierID, sendFromPreference, message ); this.m_sendSMSHttpClient.sendRequest( HTTP_VERB_POST, VM_URL.WX1, VM_URL.WX2, "text/xml", requestMessage.asXML( ) ); } catch ( e ) { this.invokeOnSendSMSFailedCallback( "Failed to send SendSMS message" ); } }, handleSendSMSResponse:function( xmlResponse ) { try { var responseMessage = new MSG_SendSMSResponse( xmlResponse ); this.invokeOnSendSMSSucceededCallback( responseMessage ); } catch ( e ) { // Failed to parse/process the response this.invokeOnSendSMSFailedCallback( "Failed to process SendSMS response" ); } }, handleSendSMSError:function( errorMessage ) { this.invokeOnSendSMSFailedCallback( errorMessage ); } } BqATRfunction CMD_CountryMetaData( name, countryCode ) { this.m_name = name; this.m_countryCode = countryCode; } var CMD_COUNTRY_CODE_CONTROL_ID = '-1'; var CMD_COUNTRY_CODE_NANP = '1'; var CMD_COUNTRY_CODES = [ new CMD_CountryMetaData( "Select Country", CMD_COUNTRY_CODE_CONTROL_ID ), new CMD_CountryMetaData( "----------------", CMD_COUNTRY_CODE_CONTROL_ID ), new CMD_CountryMetaData( "United States", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Canada", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "----------------", CMD_COUNTRY_CODE_CONTROL_ID ), new CMD_CountryMetaData( "Afghanistan", '93' ), new CMD_CountryMetaData( "Albania", '355' ), new CMD_CountryMetaData( "Algeria", '213' ), new CMD_CountryMetaData( "American Samoa", '684' ), new CMD_CountryMetaData( "Andorra", '376' ), new CMD_CountryMetaData( "Angola", '244' ), new CMD_CountryMetaData( "Anguilla, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Antigua, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Argentina", '54' ), new CMD_CountryMetaData( "Armenia", '374' ), new CMD_CountryMetaData( "Aruba", '297' ), new CMD_CountryMetaData( "Ascension", '247' ), new CMD_CountryMetaData( "Australia", '61' ), new CMD_CountryMetaData( "Australian Ext. Territories", '672' ), new CMD_CountryMetaData( "Austria", '43' ), new CMD_CountryMetaData( "Azerbaijani Republic", '994' ), new CMD_CountryMetaData( "Bahamas", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Bahrain", '973' ), new CMD_CountryMetaData( "Bangladesh", '880' ), new CMD_CountryMetaData( "Barbados", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Belarus", '375' ), new CMD_CountryMetaData( "Belgium", '32' ), new CMD_CountryMetaData( "Belize", '501' ), new CMD_CountryMetaData( "Benin", '229' ), new CMD_CountryMetaData( "Bermuda", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Bhutan", '975' ), new CMD_CountryMetaData( "Bolivia", '591' ), new CMD_CountryMetaData( "Bosnia", '387' ), new CMD_CountryMetaData( "Botswana", '267' ), new CMD_CountryMetaData( "Brazil", '55' ), new CMD_CountryMetaData( "British Virgin Islands", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Brunei Darussalam", '673' ), new CMD_CountryMetaData( "Bulgaria", '359' ), new CMD_CountryMetaData( "Burkina Faso", '226' ), new CMD_CountryMetaData( "Burundi", '257' ), new CMD_CountryMetaData( "Cambodia", '855' ), new CMD_CountryMetaData( "Cameroon", '237' ), new CMD_CountryMetaData( "Canada", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Cape Verde", '238' ), new CMD_CountryMetaData( "Cayman Islands", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Central African Republic", '236' ), new CMD_CountryMetaData( "Chad", '235' ), new CMD_CountryMetaData( "Chile", '56' ), new CMD_CountryMetaData( "China", '86' ), new CMD_CountryMetaData( "CNMI (N. Marianas),Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Colombia", '57' ), new CMD_CountryMetaData( "Comoros & Mayotte", '269' ), new CMD_CountryMetaData( "Congo", '242' ), new CMD_CountryMetaData( "Cook Islands", '682' ), new CMD_CountryMetaData( "Costa Rica", '506' ), new CMD_CountryMetaData( "Cote' D'ivoire", '225' ), new CMD_CountryMetaData( "Croatia", '385' ), new CMD_CountryMetaData( "Cuba", '53' ), new CMD_CountryMetaData( "Cyprus", '357' ), new CMD_CountryMetaData( "Czech Republic", '420' ), new CMD_CountryMetaData( "Denmark", '45' ), new CMD_CountryMetaData( "Diego Garcia", '246' ), new CMD_CountryMetaData( "Djibouti", '253' ), new CMD_CountryMetaData( "Dominica, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Dominican, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Ecuador", '593' ), new CMD_CountryMetaData( "Egypt", '20' ), new CMD_CountryMetaData( "El Salvador", '503' ), new CMD_CountryMetaData( "Equatorial Guinea", '240' ), new CMD_CountryMetaData( "Eritrea", '291' ), new CMD_CountryMetaData( "Estonia", '372' ), new CMD_CountryMetaData( "Ethiopia", '251' ), new CMD_CountryMetaData( "Falkland Islands", '500' ), new CMD_CountryMetaData( "Faroe Islands", '298' ), new CMD_CountryMetaData( "Fiji", '679' ), new CMD_CountryMetaData( "Finland", '358' ), new CMD_CountryMetaData( "France", '33' ), new CMD_CountryMetaData( "French Guiana", '594' ), new CMD_CountryMetaData( "French Polynesia", '689' ), new CMD_CountryMetaData( "Gabonese Republic", '241' ), new CMD_CountryMetaData( "Gambia", '220' ), new CMD_CountryMetaData( "Georgia", '995' ), new CMD_CountryMetaData( "Germany", '49' ), new CMD_CountryMetaData( "Ghana", '233' ), new CMD_CountryMetaData( "Gibraltar", '350' ), new CMD_CountryMetaData( "Greece", '30' ), new CMD_CountryMetaData( "Greenland", '299' ), new CMD_CountryMetaData( "Grenada", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Guadeloupe", '590' ), new CMD_CountryMetaData( "Guam", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Guatemala", '502' ), new CMD_CountryMetaData( "Guinea", '224' ), new CMD_CountryMetaData( "Guinea-Bissau", '245' ), new CMD_CountryMetaData( "Guyana", '592' ), new CMD_CountryMetaData( "Haiti", '509' ), new CMD_CountryMetaData( "Honduras", '504' ), new CMD_CountryMetaData( "Hong Kong", '852' ), new CMD_CountryMetaData( "Hungary", '36' ), new CMD_CountryMetaData( "Iceland", '354' ), new CMD_CountryMetaData( "India", '91' ), new CMD_CountryMetaData( "Indonesia", '62' ), new CMD_CountryMetaData( "Iran", '98' ), new CMD_CountryMetaData( "Iraq", '964' ), new CMD_CountryMetaData( "Ireland", '353' ), new CMD_CountryMetaData( "Israel", '972' ), new CMD_CountryMetaData( "Italy", '39' ), new CMD_CountryMetaData( "Jamaica", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Japan", '81' ), new CMD_CountryMetaData( "Jordan", '962' ), new CMD_CountryMetaData( "Kenya", '254' ), new CMD_CountryMetaData( "Kiribati", '686' ), new CMD_CountryMetaData( "Korea", '82' ), new CMD_CountryMetaData( "Kuwait", '965' ), new CMD_CountryMetaData( "Kyrgyz Republic", '996' ), new CMD_CountryMetaData( "Laos", '856' ), new CMD_CountryMetaData( "Latvia", '371' ), new CMD_CountryMetaData( "Lebanon", '961' ), new CMD_CountryMetaData( "Lesotho", '266' ), new CMD_CountryMetaData( "Liberia", '231' ), new CMD_CountryMetaData( "Libya", '218' ), new CMD_CountryMetaData( "Liechtenstein", '423' ), new CMD_CountryMetaData( "Lithuania", '370' ), new CMD_CountryMetaData( "Luxembourg", '352' ), new CMD_CountryMetaData( "Macau", '853' ), new CMD_CountryMetaData( "Macedonia", '389' ), new CMD_CountryMetaData( "Madagascar", '261' ), new CMD_CountryMetaData( "Malawi", '265' ), new CMD_CountryMetaData( "Malaysia", '60' ), new CMD_CountryMetaData( "Maldives", '960' ), new CMD_CountryMetaData( "Mali", '223' ), new CMD_CountryMetaData( "Malta", '356' ), new CMD_CountryMetaData( "Marshall Islands", '692' ), new CMD_CountryMetaData( "Martinique", '596' ), new CMD_CountryMetaData( "Mauritania", '222' ), new CMD_CountryMetaData( "Mauritius", '230' ), new CMD_CountryMetaData( "Mexico", '52' ), new CMD_CountryMetaData( "Micronesia", '691' ), new CMD_CountryMetaData( "Moldova", '373' ), new CMD_CountryMetaData( "Monaco", '377' ), new CMD_CountryMetaData( "Mongolia", '976' ), new CMD_CountryMetaData( "Montserrat, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Morocco", '212' ), new CMD_CountryMetaData( "Mozambique", '258' ), new CMD_CountryMetaData( "Myanmar", '95' ), new CMD_CountryMetaData( "Namibia", '264' ), new CMD_CountryMetaData( "Nauru", '674' ), new CMD_CountryMetaData( "Nepal", '977' ), new CMD_CountryMetaData( "Netherlands", '31' ), new CMD_CountryMetaData( "Netherlands Antilles", '599' ), new CMD_CountryMetaData( "New Caledonia", '687' ), new CMD_CountryMetaData( "New Zealand", '64' ), new CMD_CountryMetaData( "Nicaragua", '505' ), new CMD_CountryMetaData( "Niger", '227' ), new CMD_CountryMetaData( "Nigeria", '234' ), new CMD_CountryMetaData( "Niue", '683' ), new CMD_CountryMetaData( "North Korea", '850' ), new CMD_CountryMetaData( "Norway", '47' ), new CMD_CountryMetaData( "Oman", '968' ), new CMD_CountryMetaData( "Pakistan", '92' ), new CMD_CountryMetaData( "Palau", '680' ), new CMD_CountryMetaData( "Panama", '507' ), new CMD_CountryMetaData( "Papua New Guinea", '675' ), new CMD_CountryMetaData( "Paraguay", '595' ), new CMD_CountryMetaData( "Peru", '51' ), new CMD_CountryMetaData( "Philippines", '63' ), new CMD_CountryMetaData( "Poland", '48' ), new CMD_CountryMetaData( "Portugal", '351' ), new CMD_CountryMetaData( "Puerto Rico", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Qatar", '974' ), new CMD_CountryMetaData( "Reunion", '262' ), new CMD_CountryMetaData( "Romania", '40' ), new CMD_CountryMetaData( "Russia/Kazakhstan", '7' ), new CMD_CountryMetaData( "Rwandese Republic", '250' ), new CMD_CountryMetaData( "Saint Helena", '290' ), new CMD_CountryMetaData( "St. Kitts & Nevis, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "St. Lucia", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Saint Pierre and Miquelon", '508' ), new CMD_CountryMetaData( "St. Vincent, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Samoa", '685' ), new CMD_CountryMetaData( "San Marino", '378' ), new CMD_CountryMetaData( "Sao Tome and Principe", '239' ), new CMD_CountryMetaData( "Saudi Arabia", '966' ), new CMD_CountryMetaData( "Senegal", '221' ), new CMD_CountryMetaData( "Seychelles", '248' ), new CMD_CountryMetaData( "Sierra Leone", '232' ), new CMD_CountryMetaData( "Singapore", '65' ), new CMD_CountryMetaData( "Slovak Republic", '421' ), new CMD_CountryMetaData( "Slovenia", '386' ), new CMD_CountryMetaData( "Solomon Islands", '677' ), new CMD_CountryMetaData( "Somalia", '252' ), new CMD_CountryMetaData( "South Africa", '27' ), new CMD_CountryMetaData( "Spain", '34' ), new CMD_CountryMetaData( "Sri Lanka", '94' ), new CMD_CountryMetaData( "Sudan", '249' ), new CMD_CountryMetaData( "Suriname", '597' ), new CMD_CountryMetaData( "Swaziland", '268' ), new CMD_CountryMetaData( "Sweden", '46' ), new CMD_CountryMetaData( "Switzerland", '41' ), new CMD_CountryMetaData( "Syria", '963' ), new CMD_CountryMetaData( "Taiwan", '886' ), new CMD_CountryMetaData( "Tajikistan", '992' ), new CMD_CountryMetaData( "Tanzania", '255' ), new CMD_CountryMetaData( "Thailand", '66' ), new CMD_CountryMetaData( "Timor-Leste", '670' ), new CMD_CountryMetaData( "Togolese Republic", '228' ), new CMD_CountryMetaData( "Tokelau", '690' ), new CMD_CountryMetaData( "Tonga", '676' ), new CMD_CountryMetaData( "Trinidad & Tobago, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Tunisia", '216' ), new CMD_CountryMetaData( "Turkey", '90' ), new CMD_CountryMetaData( "Turkmenistan", '993' ), new CMD_CountryMetaData( "Turks & Caicos, Island", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Tuvalu", '688' ), new CMD_CountryMetaData( "Uganda", '256' ), new CMD_CountryMetaData( "Ukraine", '380' ), new CMD_CountryMetaData( "United Arab Emirates", '971' ), new CMD_CountryMetaData( "United Kingdom", '44' ), new CMD_CountryMetaData( "United States", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "US Virgin Islands", CMD_COUNTRY_CODE_NANP ), new CMD_CountryMetaData( "Uruguay", '598' ), new CMD_CountryMetaData( "Uzbekistan", '998' ), new CMD_CountryMetaData( "Vanuatu", '678' ), new CMD_CountryMetaData( "Vatican City State", '379' ), new CMD_CountryMetaData( "Venezuela", '58' ), new CMD_CountryMetaData( "Vietnam", '84' ), new CMD_CountryMetaData( "Wallis and Futuna", '681' ), new CMD_CountryMetaData( "Yemen", '967' ), new CMD_CountryMetaData( "Yugoslavia", '381' ), new CMD_CountryMetaData( "Zaire", '243' ), new CMD_CountryMetaData( "Zambia", '260' ), new CMD_CountryMetaData( "Zimbabwe", '263' ) ]; hYDfunction CWError( name, message ) { this.name = name; this.message = this.name + ": " + ( message ? message : '' ); } CWError.prototype = { Nest: function( error ) { this.message += '\n'; var err = (error == undefined) ? 'UNDEFINED_EXCEPTION!' : error; this.message += err.name ? err.name : err; this.message += ": "; this.message += err.message ? err.message : ''; this.message += err.number ? '\nNumber: ' + err.number : ''; this.message += err.description ? '\nDescription: ' + err.description : ''; this.message += err.fileName ? '\nFile: ' + err.fileName : ''; this.message += err.lineNumber ? '\nLine: ' + err.lineNumber : ''; this.message += err.stack ? '\nStack:\n' + err.stack : ''; this.message.replace( /\n/, '\t\n' ); /* TODO - I think this is a no-op because replace is non-descructive, right? - IKS */ } } function EX_ASSERT_NO_EXCEPTIONS( error, message ) { var theError = new CWError( 'Unhandled exception', message ); theError.Nest( error ); throw theError; } // override this to do something useful function EX_Log( message ) { } function TYPE_EX_FailedParsingCarrier( nestedException ) { EXT_extend( this, new CWError( 'TYPE_EX_FailedParsingCarrier' ) ); this.Nest( nestedException ); } function TYPE_EX_FailedParsingCarrierList( nestedException ) { EXT_extend( this, new CWError( 'TYPE_EX_FailedParsingCarrierList' ) ); this.Nest( nestedException ); } function TYPE_EX_FailedParsingForwardCodeList( nestedException ) { EXT_extend( this, new CWError( 'TYPE_EX_FailedParsingForwardCodeList' ) ); this.Nest( nestedException ); } function TYPE_EX_FailedParsingForwardCode( nestedException ) { EXT_extend( this, new CWError( 'TYPE_EX_FailedParsingForwardCode' ) ); this.Nest( nestedException ); } vVR]TR/****************************************************************************** Extend function to support inheritance. A child class extends a base class by invoking extend( ) in its constructor, passing itself and an instance of the base class as a parameter to the extend function. E.g. function BaseClass( parameter1 ) { this.m_attribute1 = parameter1; } function ChildClass( parameter1, parameter2 ) { EXT_extend( this, new BaseClassConstructor( parameter1 ) ); this.m_attribute2 = parameter2; } ******************************************************************************/ function EXT_extend( child, base ) { var p; for ( p in base ) { if ( p !== 'constructor' ) { child[ p ] = base[ p ]; } } } 9_Y function HTTP_EX_SendRequestFailed( exception ) { EXT_extend( this, new CWError( 'HTTP_EX_SendRequestFailed' ) ); this.Nest( exception ); } function HTTP_EX_FailoverFailed( exception ) { EXT_extend( this, new CWError( 'HTTP_EX_FailoverFailed' ) ); this.Nest( exception ); } function HTTP_EX_RedirectFailed( exception ) { EXT_extend( this, new CWError( 'HTTP_EX_RedirectFailed' ) ); this.Nest( exception ); } 4d4R]/************************************************************** HttpClient class. This class provides support for GET and POST requests with failover and redirects.. **************************************************************/ var HTTP_VERB_GET = 'GET'; var HTTP_VERB_POST = 'POST'; //-- HTTP states --- var HTTP_STATE_NONE = 0; var HTTP_STATE_PRIMARY = 1; var HTTP_STATE_FAILOVER = 2; var HTTP_DEFAULT_REQUEST_TIMEOUT_SECONDS = 30; function HttpClient( ) { } HttpClient.prototype = { m_verb : '', m_url : '', m_failoverUrl : '', m_contentType : '', m_xmlhttp : null, m_requestData : '', m_state : HTTP_STATE_NONE, m_timeoutSecs : HTTP_DEFAULT_REQUEST_TIMEOUT_SECONDS, m_requestTimer : null, m_yahooRequestTimer : null, // call backs onSuccess : null, onError : null, onRedirect : null, onFailover : null, /******************************************************** PUBLIC METHODS ********************************************************/ IsRequestInProgress: function( ) { return ( this.m_state != HTTP_STATE_NONE ); }, sendRequest:function( verb, url, failoverUrl, contentType, requestData, timeoutSecs ) { // precondition if ( this.m_state != HTTP_STATE_NONE ) { throw new Error( "HttpClient - request in progress!" ); } try { this.m_state = HTTP_STATE_PRIMARY; this.m_verb = verb; this.m_url = url; this.m_failoverUrl = failoverUrl; this.m_contentType = contentType; this.m_requestData = requestData; this.m_timeoutSecs = HTTP_DEFAULT_REQUEST_TIMEOUT_SECONDS; if ( ( typeof timeoutSecs != 'undefined' ) && timeoutSecs != 0 ) { this.m_timeoutSecs = timeoutSecs; } this.PrepareRequest( ); this.Send( ); } catch( e ) { this.reset( ); throw new HTTP_EX_SendRequestFailed( e ); } }, reset:function( ) { try { this.CancelRequest( ); if ( this.m_xmlhttp != null ) { delete this.m_xmlhttp["onreadystatechange"]; // Need to get rid of the object in IE so that // failures handled by ProcessResponse( ) reset // the members. In the case of aborted requests // from timeouts, this is not needed: go figure... this.m_xmlhttp = null; } this.m_state = HTTP_STATE_NONE; } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "reset( )" ); } }, /******************************************************** PRIVATE METHODS ********************************************************/ PrepareRequest:function( ) { if ( this.m_xmlhttp != null ) { this.m_xmlhttp.abort( ); return; } try { // Mozilla / Safari / IE7 this.m_xmlhttp = new XMLHttpRequest( ); } catch( e ) { var XMLHTTP_IDS = new Array('MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP' ); for( var i = 0; i < XMLHTTP_IDS.length; i++ ) { try { this.m_xmlhttp = new ActiveXObject( XMLHTTP_IDS[i] ); // if we get here then the creation didn't fail // so return, since we're done. return; } catch( e ) { } } // if we get here we failed creating the object throw new Error('Unable to create XMLHttpRequest.'); } }, Send: function( ) { try { // precondition if ( this.m_state == HTTP_STATE_NONE ) { throw new Error( "HttpClient::Send( ) - Invalid state" ); } try { var requestURL = ( this.m_state == HTTP_STATE_PRIMARY ? this.m_url : this.m_failoverUrl ); if ( this.m_verb == HTTP_VERB_GET && this.m_requestData != '' ) { requestURL = requestURL + '?' + this.m_requestData; } // set onreadystatechange here since it will be reset after a //completed call in Mozilla delete this.m_xmlhttp[ "onreadystatechange" ]; var self = this; this.m_xmlhttp.onreadystatechange = function( ) { self.ProcessResponse( ); }; // send async request this.m_xmlhttp.open( this.m_verb, requestURL, true ); if ( this.m_verb == HTTP_VERB_GET ) { this.m_xmlhttp.send( null ); } else { this.m_xmlhttp.send( this.m_requestData ); } this.StartRequestTimeout( ); } catch ( e ) { if ( this.m_state != HTTP_STATE_PRIMARY ) { throw e; } this.PerformFailover( ); } } catch( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "HttpClient::Send( )" ); } }, ProcessResponse:function( ) { try { if ( this.m_xmlhttp.readyState != 4 ) // only if req shows 'loaded' { return; } this.CancelRequestTimeout( ); if ( this.m_xmlhttp.status == 200 ) { if ( this.m_xmlhttp.responseXML == null ) { this.HandleAsyncError( 'XML response is empty. Response = ' + this.m_xmlhttp.responseText ); return; } this.HandleSuccess( this.m_xmlhttp.responseXML ); return; } // handle redirects if( this.m_xmlhttp.status == 301 || this.m_xmlhttp.status == 302 || this.m_xmlhttp.status == 305 ) { this.PerformRedirect( ); return; } if ( this.m_state == HTTP_STATE_PRIMARY ) { if ( this.m_xmlhttp.status == 400 ) { VM_URL.set_areRedirectsAllowed( false ); } this.PerformFailover( ); return; } this.HandleAsyncError( ); } catch( e ) { this.HandleAsyncError( "HttpClient::ProcessResponse( ) failed.", e ); } }, CancelRequest:function( ) { try { this.CancelRequestTimeout( ); if ( this.m_xmlhttp != null ) { this.m_xmlhttp.abort( ); } } catch( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "HttpClient::CancelRequest( )" ); } }, HandleRequestTimeout:function( ) { try { this.CancelRequest( ); switch ( this.m_state ) { case HTTP_STATE_NONE: return; case HTTP_STATE_PRIMARY: { this.PerformFailover( ); } return; case HTTP_STATE_FAILOVER: { this.HandleAsyncError( null, null, 'Request timed out' ); } return; } } catch( e ) { EX_Log( "HttpClient::HandleRequestTimeout( ) failed " + e.message ); } }, PerformFailover:function( ) { try { this.CancelRequest( ); this.m_state = HTTP_STATE_FAILOVER; try { if ( this.onFailover != null ) { this.onFailover( this.m_failoverUrl ); } } catch ( e ) { EX_Log( "HttpClient::PerformFailover( ) caught exception from onFailover call back\n" + e.message ); } this.Send( ); } catch ( e ) { this.HandleAsyncError( "HttpClient::PerformFailover( ) failed", new HTTP_EX_FailoverFailed( e ) ); } }, PerformRedirect:function( ) { try { var redirectURL = this.m_xmlhttp.getResponseHeader( 'Location' ); if ( this.m_state == HTTP_STATE_PRIMARY ) { this.m_url = redirectURL; } else { this.m_failoverUrl = redirectURL; } this.CancelRequest( ); try { if ( this.onRedirect != null ) { this.onRedirect( redirectURL ); } } catch ( e ) { EX_Log( "HttpClient::PerformRedirect( ) caught exception from onRedirect call back\n" + e.message ); } this.Send( ); } catch( e ) { this.HandleAsyncError( "HttpClient::PerformRedirect( ) failed", new HTTP_EX_RedirectFailed( e ) ); } }, HandleAsyncError: function( logMessage, exception, userMessage ) { try { if ( logMessage || exception ) { var message = ( logMessage ? logMessage : '' ); if ( exception ) { message += ( logMessage ? '\n' : '' ) + exception.message; } EX_Log( message ); } this.reset( ); if ( this.onError != null ) { this.onError( userMessage ? userMessage : 'Unable to process HTTP request. Please try again later.' ); } } catch ( e ) { EX_Log( "HttpClient::HandleAsyncError( ) caught exception\n" + e.message ); } }, HandleSuccess: function( responseXML ) { try { try { if ( this.onSuccess != null ) { this.onSuccess( responseXML ); } } catch ( e ) { EX_Log( "HttpClient::HandleSuccess( ) caught exception from onSuccess call back\n" + e.message ); } this.reset( ); } catch ( e ) { EX_Log( "HttpClient::HandleSuccess( ) caught exception\n" + e.message ); } }, StartRequestTimeout:function( ) { try { if ( this.m_timeoutSecs == 0 ) { return; } var self = this; if ( typeof VM_WIDGET_SOURCE != 'undefined' && ( VM_WIDGET_SOURCE == "Y" || VM_WIDGET_SOURCE == "SY" ) ) { this.m_yahooRequestTimer = new Timer( ); this.m_yahooRequestTimer.interval = this.m_timeoutSecs; this.m_yahooRequestTimer.onTimerFired = function( ) { self.HandleRequestTimeout( ); } this.m_yahooRequestTimer.ticking = true; } else { this.m_requestTimer = setTimeout( function( ) { self.HandleRequestTimeout(); }, this.m_timeoutSecs * 1000 ); } } catch( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "HttpClient::StartRequestTimeout( )" ); } }, CancelRequestTimeout:function( ) { try { if ( this.m_yahooRequestTimer != null ) { this.m_yahooRequestTimer.ticking = false; this.m_yahooRequestTimer.onTimerFired = ""; this.m_yahooRequestTimer = null; } if ( this.m_requestTimer != null ) { clearTimeout( this.m_requestTimer ); this.m_requestTimer = null; } } catch( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "HttpClient::CancelRequestTimeout( )" ); } } };  }9_var VM_URL = { WWW: "http://www.callwave.com", WS1: null, WS2: null, WX1: null, WX2: null, WSS1: null, WSS2: null, m_targetService: "v2w", m_areServersRestricted: false, m_isLoadBalancingEnabled: false, m_areRedirectsAllowed: true, set_targetService: function( svc ) { this.m_targetService = svc; this._updateUrls( ); }, set_WWW_SERVER: function( WWW_SERVER ) { this.WWW = WWW_SERVER; this._updateUrls( ); }, set_areServersRestricted: function( bool ) { this.m_areServersRestricted = bool; this._updateUrls( ); }, set_isLoadBalancingEnabled: function( bool ) { this.m_isLoadBalancingEnabled = bool; this._updateUrls( ); }, set_areRedirectsAllowed: function( bool ) { this.m_areRedirectsAllowed = bool; this._updateUrls( ); }, _updateUrls: function( ) { var wxServerName = "http://wx", wxPath = "/v2w", webServicePath = "/widgets/" + this.m_targetService + "/service.aspx", webProxyPath = "/widgets/" + this.m_targetService + "/proxy.aspx?url="; if ( this.m_isLoadBalancingEnabled ) { wxServerName += "lb"; wxPath = "/wx" + wxPath; } else { wxServerName += typeof VM_GetPreference != 'undefined' && VM_GetPreference( PREF_KEY_ACCOUNT ) ? ( parseInt( VM_GetPreference( PREF_KEY_ACCOUNT ) ) % 32 ).toString( ) : "0"; } this.WX1 = wxServerName + ".callwave.com" + wxPath; this.WX2 = wxServerName + ".gotpb.com" + wxPath; if ( ( !this.m_isLoadBalancingEnabled && this.m_areServersRestricted ) || !this.m_areRedirectsAllowed ) { this.WX1 = this.WWW + webProxyPath + encodeURIComponent( this.WX1 ); this.WX2 = this.WWW + webProxyPath + encodeURIComponent( this.WX2 ); } this.WS1 = this.WWW + webServicePath; this.WS2 = this.WS1.replace( /callwave/, "gotpb" ); // only used by non Google clients this.WSS1 = this.WS1.replace( /http/, "https" ); this.WSS2 = this.WSS1.replace( /callwave/, "gotpb" ); if ( this.m_areServersRestricted ) { this.WS2 = this.WS1; } } }; tT function MSG_EX_FailedCreatingRegisterAccountResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingRegisterAccountResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingGetCallsResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingGetCallsResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingSetCarrierInfoResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingSetCarrierInfoResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingActivateAccountResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingActivateAccountResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingGetAccountInfoResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingGetAccountInfoResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingAuthenticateResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingAuthenticateResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingForgotPinResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingForgotPinResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingGetCallsResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingGetCallsResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingVerifyPhoneResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingVerifyPhoneResponse' ) ); this.Nest( exception ); } function MSG_EX_FailedCreatingSendSMSResponse( exception ) { EXT_extend( this, new CWError( 'MSG_EX_FailedCreatingSendSMSResponse' ) ); this.Nest( exception ); } function MSG_EX_WrongMessageType( type, expectedType ) { EXT_extend( this, new CWError( 'MSG_EX_WrongMessageType', type + ' Expected := ' + expectedType ) ); } function MSG_EX_EmptyResponse( ) { EXT_extend( this, new CWError( 'MSG_EX_EmptyResponse' ) ); } 33}/****************************************************************************** Dependencies: Shared/Extensions/Object.js Shared/Calls/Calls.js ******************************************************************************/ /****************************************************************************** Constants ******************************************************************************/ // Message Type enum var MSG_MESSAGE_TYPE_REGISTER_ACCOUNT = "REGA"; var MSG_MESSAGE_TYPE_SET_CARRIER_INFO = "SETC"; var MSG_MESSAGE_TYPE_GET_ACCOUNT_INFO = "GETA"; var MSG_MESSAGE_TYPE_AUTHENTICATE = "AUTH"; var MSG_MESSAGE_TYPE_FORGOT_PIN = "FPIN"; var MSG_MESSAGE_TYPE_GET_CALLS = "GCAL"; var MSG_MESSAGE_TYPE_VERIFY_PHONE = "VPHO"; var MSG_MESSAGE_TYPE_SEND_SMS = "SSMS"; // Widget Source enum var MSG_WIDGET_TYPE_MAC_OS_X = 'X'; var MSG_WIDGET_TYPE_YAHOO = 'Y'; var MSG_WIDGET_TYPE_GOOGLE = 'G'; var MSG_XML_HEADER = ""; var MSG_XML_REQUEST_ELEMENT_NAME = "request"; /****************************************************************************** Definitions ******************************************************************************/ /****************************************************************************** MSG_RequestBase class ******************************************************************************/ function MSG_RequestBase( messageType, source, version, os ) { this.m_type = messageType; this.m_src = source; this.m_ver = version; this.m_os = os; } MSG_RequestBase.prototype = { baseAsXML:function( ) { var requestContent = this.asXMLElement( "type", this.m_type ) + this.asXMLElement( "src", this.m_src ) + this.asXMLElement( "ver", this.m_ver ) + this.asXMLElement( "os", this.m_os ); return requestContent; }, asXMLElement:function( name, value, doNotEscape ) { return UTILS.asXmlString( name, value, doNotEscape ); } } /****************************************************************************** MSG_RegisterAccountRequest class ******************************************************************************/ function MSG_RegisterAccountRequest( source, version, os, phoneNumber, pin, emailAddress ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_REGISTER_ACCOUNT, source, version, os ) ); this.m_phone = phoneNumber; this.m_pin = pin; this.m_email = emailAddress; } MSG_RegisterAccountRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "phone", this.m_phone ) + this.asXMLElement( "pin", this.m_pin ) + this.asXMLElement( "email", this.m_email ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_SetCarrierInfoRequest class ******************************************************************************/ function MSG_SetCarrierInfoRequest( source, version, os, account, uString, carrierId ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_SET_CARRIER_INFO, source, version, os ) ); this.m_account = account; this.m_uString = uString; this.m_carrierId = carrierId; } MSG_SetCarrierInfoRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "account", this.m_account ) + this.asXMLElement( "uString", this.m_uString ) + this.asXMLElement( "carrierId", this.m_carrierId ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_VerifyPhoneRequest class ******************************************************************************/ function MSG_VerifyPhoneRequest( source, version, os, account, uString, verificationCode, phoneCC, phoneNN ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_VERIFY_PHONE, source, version, os ) ); this.m_account = account; this.m_uString = uString; this.m_verificationCode = verificationCode; this.m_phoneCC = phoneCC; this.m_phoneNN = phoneNN; } MSG_VerifyPhoneRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "account", this.m_account ) + this.asXMLElement( "uString", this.m_uString ) + this.asXMLElement( "verificationCode", this.m_verificationCode ) + this.asXMLElement( "phoneCC", this.m_phoneCC ) + this.asXMLElement( "phoneNN", this.m_phoneNN ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_GetAccountInfoRequest class ******************************************************************************/ function MSG_GetAccountInfoRequest( source, version, os, accountNumber, uString ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_GET_ACCOUNT_INFO, source, version, os ) ); this.m_account = accountNumber; this.m_uString = uString; } MSG_GetAccountInfoRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "account", this.m_account ) + this.asXMLElement( "uString", this.m_uString ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_AuthenticateRequest class ******************************************************************************/ function MSG_AuthenticateRequest( source, version, os, phoneNumber, pin ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_AUTHENTICATE, source, version, os ) ); this.m_phone = phoneNumber; this.m_pin = pin; } MSG_AuthenticateRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "phone", this.m_phone ) + this.asXMLElement( "pin", this.m_pin ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_ForgotPinRequest class ******************************************************************************/ function MSG_ForgotPinRequest( source, version, os, phoneNumber ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_FORGOT_PIN, source, version, os ) ); this.m_phone = phoneNumber; } MSG_ForgotPinRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "phone", this.m_phone ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_GetCallsRequest class ******************************************************************************/ function MSG_GetCallsRequest( source, version, os, accountNumber, uString, syncLevel, callUpdateList, maxCalls ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_GET_CALLS, source, version, os ) ); this.m_account = accountNumber; this.m_uString = uString; this.m_syncLevel = syncLevel; this.m_callUpdates = callUpdateList; this.m_maxCalls = maxCalls; } MSG_GetCallsRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "account", this.m_account ) + this.asXMLElement( "uString", this.m_uString ) + this.asXMLElement( "syncLevel", this.m_syncLevel ) + this.m_callUpdates.asXML( ) + this.asXMLElement( "maxCalls", this.m_maxCalls ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } /****************************************************************************** MSG_SendSMSRequest class ******************************************************************************/ function MSG_SendSMSRequest( source, version, os, accountNumber, uString, sendToPhoneNumber, sendToCarrierID, sendFromPreference, message ) { EXT_extend( this, new MSG_RequestBase( MSG_MESSAGE_TYPE_SEND_SMS, source, version, os ) ); this.m_account = accountNumber; this.m_uString = uString; this.m_sendToPhoneNumber = sendToPhoneNumber; this.m_sendToCarrierID = sendToCarrierID; this.m_sendFromPreference = sendFromPreference; this.m_message = message; } MSG_SendSMSRequest.prototype = { asXML:function( ) { var requestContent = this.baseAsXML( ) + this.asXMLElement( "account", this.m_account ) + this.asXMLElement( "uString", this.m_uString ) + this.asXMLElement( "sendToPhoneNumber", this.m_sendToPhoneNumber ) + this.asXMLElement( "sendToCarrierID", this.m_sendToCarrierID ) + this.asXMLElement( "sendFromPreference", this.m_sendFromPreference ) + this.asXMLElement( "message", this.m_message ); // Do not escape the message body return MSG_XML_HEADER + this.asXMLElement( MSG_XML_REQUEST_ELEMENT_NAME, requestContent, true ); } } s1>S14 /****************************************************************************** Dependencies: Shared/Extensions/Object.js Shared/XML/XML.js Shared/XML/Exceptions.js Shared/Calls/Calls.js Shared/Types.js ******************************************************************************/ /****************************************************************************** Constants ******************************************************************************/ var MSG_XML_RESPONSE_ELEMENT_NAME = "response"; /****************************************************************************** MSG_ResponseStatus Defines all the response status codes for every response message. ******************************************************************************/ var MSG_ResponseStatus = { // generic response statuses SUCCESS : 0, UNEXPECTED_ERROR : 1, GENERAL_ERROR : 2, RECOVERABLE_ERROR : 3, REGA_PIN_MISMATCH : 10, SETC_LOGIN_FAILURE : 11, VPHO_LOGIN_FAILURE : 11, VPHO_COUNTRY_NOT_SUPPORTED : 12, AUTH_PIN_MISMATCH : 10, AUTH_ACCOUNT_LOCKED : 11, AUTH_UPGRADE_REQUIRED : 12, GETA_LOGIN_FAILURE : 11, GETA_ACCOUNT_NOT_FOUND : 2, GETA_UPGRADE_REQUIRED : 12, GCAL_LOGIN_FAILURE : 11, GCAL_ACCOUNT_NOT_FOUND : 2, SSMS_LOGIN_REQUIRED : 11 }; /****************************************************************************** MSG_ResponseBase ******************************************************************************/ function MSG_ResponseBase( xmlDom ) { this.m_type = ''; this.m_status = MSG_ResponseStatus.SUCCESS; this.m_statusMsg = ''; this.xmlProperties_base = ["type", "status", "statusMsg"]; this.xmlProperties = this.xmlProperties_base; this.xmlTopTag = ''; // TODO -- make it this MSG_XML_RESPONSE_ELEMENT_NAME; this.expectedType = null; if ( xmlDom ) { this.initFromXml( xmlDom ); } else if (this.expectedType) { throw new MSG_EX_EmptyResponse( "No XML DOM passed to constructor. Expected xmlDom with type[" + this.expectedType + "]" ); } } MSG_ResponseBase.prototype = { initFromXml: function(xmlDom) { if ( ! xmlDom.firstChild ) { throw new MSG_EX_EmptyResponse( ); } XML_InitializeMembersFromXML( xmlDom, this, MSG_XML_RESPONSE_ELEMENT_NAME ); if ( this.expectedType && this.m_type != this.expectedType ) { throw new MSG_EX_WrongMessageType( this.m_type, this.expectedType ); } // make integer values integers this.m_status = parseInt( this.m_status ); }, asXML: function() { var topTag = this.xmlTopTag; if ((!topTag || topTag.length == 0) && this.expectedType) { // XML_RESPONSE if not tag or blank tag specifified AND expectedType specified // TODO - This logic can go away and be just topTag = this.xmlTopTag // if we can show that MSG_GetResponseBaseXMLTags is only used in this file. topTag = MSG_XML_RESPONSE_ELEMENT_NAME; } return UTILS.propertiesAsXml( this, this.xmlProperties, topTag ); } } function MSG_GetResponseBaseXMLTags( obj ) { return UTILS.propertiesAsXml( obj, obj.xmlProperties_base ); } /****************************************************************************** MSG_RegisterAccountResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingRegisterAccountResponse ******************************************************************************/ function MSG_RegisterAccountResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); // add some items for the base asXML() to work with this.xmlProperties.push( 'account' ); this.xmlProperties.push( 'uString' ); this.xmlProperties.push( 'successCase' ); // initialize the attributes this.m_account = 0; this.m_uString = ''; this.m_successCase = 0; this.expectedType = MSG_MESSAGE_TYPE_REGISTER_ACCOUNT; this.initFromXml( xmlResponse ); // make integer values integers this.m_account = parseInt( this.m_account ); this.m_successCase = parseInt( this.m_successCase ); } catch ( e ) { throw new MSG_EX_FailedCreatingRegisterAccountResponse( e ); } } /****************************************************************************** MSG_SetCarrierInfoResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingSetCarrierInfoResponse ******************************************************************************/ function MSG_SetCarrierInfoResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); this.expectedType = MSG_MESSAGE_TYPE_SET_CARRIER_INFO; this.initFromXml( xmlResponse ); } catch ( e ) { throw new MSG_EX_FailedCreatingSetCarrierInfoResponse( e ); } } /****************************************************************************** MSG_VerifyPhoneResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingSetCarrierInfoResponse ******************************************************************************/ function MSG_VerifyPhoneResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); this.xmlProperties.push( 'successCase' ); this.m_successCase = 0; this.expectedType = MSG_MESSAGE_TYPE_VERIFY_PHONE; this.initFromXml( xmlResponse ); // make integer values integers this.m_successCase = parseInt( this.m_successCase ); } catch ( e ) { throw new MSG_EX_FailedCreatingVerifyPhoneResponse( e ); } } /****************************************************************************** MSG_GetAccountInfoResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingGetAccountInfoResponse ******************************************************************************/ function MSG_GetAccountInfoResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); // add some items for the base asXML() to work with this.xmlProperties.push( 'phone' ); this.xmlProperties.push( 'email' ); this.xmlProperties.push( 'name' ); this.xmlProperties.push( 'actStatus' ); this.xmlProperties.push( 'carrierId' ); this.xmlProperties.push( 'fwdCodes' ); this.xmlProperties.push( 'carriers' ); this.xmlProperties.push( 'secondsBetweenSync' ); // this was not in the asXML of the previous version but it makes it easier to compare values when testing. this.xmlProperties.push( 'phoneCC' ); this.xmlProperties.push( 'phoneNN' ); this.xmlProperties.push( 'phoneVerified' ); this.xmlProperties.push( 'smsBodyOH' ); // sms body overhead to account for server inserted text this.xmlProperties.push( 'maxSMSParts' ); this.xmlProperties.push( 'showCarriers' ); // determines whether to show carrier selection pull-down for NANP customers // initialize the attributes this.m_phone = ''; this.m_email = ''; this.m_name = ''; this.m_actStatus = ''; this.m_carrierId = 0; this.m_fwdCodes = null; this.m_carriers = null; this.m_secondsBetweenSync = 0; this.m_phoneCC = ''; this.m_phoneNN = ''; this.m_phoneVerified = 0; this.m_smsBodyOH = 0; this.m_maxSMSParts = 0; this.m_showCarriers = 0; this.expectedType = MSG_MESSAGE_TYPE_GET_ACCOUNT_INFO; this.initFromXml( xmlResponse ); // make integer values integers this.m_carrierId = parseInt( this.m_carrierId ); this.m_secondsBetweenSync = parseInt( this.m_secondsBetweenSync ); this.m_phoneVerified = parseInt( this.m_phoneVerified ); this.m_smsBodyOH = parseInt( this.m_smsBodyOH ); this.m_maxSMSParts = parseInt( this.m_maxSMSParts ); this.m_showCarriers = parseInt( this.m_showCarriers ); } catch ( e ) { throw new MSG_EX_FailedCreatingGetAccountInfoResponse( e ); } } /****************************************************************************** MSG_AuthenticateResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingAuthenticateResponse ******************************************************************************/ function MSG_AuthenticateResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); // add some items for the base asXML() to work with this.xmlProperties.push( 'account' ); this.xmlProperties.push( 'uString' ); // initialize the attributes this.m_account = 0; this.m_uString = ''; this.expectedType = MSG_MESSAGE_TYPE_AUTHENTICATE; this.initFromXml( xmlResponse ); // make integer values integers this.m_account = parseInt( this.m_account ); } catch ( e ) { throw new MSG_EX_FailedCreatingAuthenticateResponse( e ); } } /****************************************************************************** MSG_ForgotPinResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingForgotPinResponse ******************************************************************************/ function MSG_ForgotPinResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); this.expectedType = MSG_MESSAGE_TYPE_FORGOT_PIN; this.initFromXml( xmlResponse ); } catch ( e ) { throw new MSG_EX_FailedCreatingForgotPinResponse( e ); } } /****************************************************************************** MSG_GetCallsResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingGetCallsResponse ******************************************************************************/ function MSG_GetCallsResponse( xmlDOMTree ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); // add some items for the base asXML() to work with this.xmlProperties.push( 'tz' ); this.xmlProperties.push( 'newSyncLevel' ); this.xmlProperties.push( 'successCase' ); this.xmlProperties.push( 'numNewCalls' ); this.xmlProperties.push( 'calls' ); // initialize the attributes this.m_tz = ''; this.m_newSyncLevel = 0; this.m_successCase = 0; this.m_numNewCalls = 0; this.m_calls = null; this.expectedType = MSG_MESSAGE_TYPE_GET_CALLS; this.initFromXml( xmlDOMTree ); // make integer values integers this.m_newSyncLevel = parseInt( this.m_newSyncLevel ); this.m_successCase = parseInt( this.m_successCase ); this.m_numNewCalls = parseInt( this.m_numNewCalls ); } catch ( e ) { throw new MSG_EX_FailedCreatingGetCallsResponse( e ); } } /****************************************************************************** MSG_SendSMSResponse c'tor Constructs the message from an XML DOM tree. Exceptions: MSG_EX_FailedCreatingSendSMSResponse ******************************************************************************/ function MSG_SendSMSResponse( xmlResponse ) { try { EXT_extend( this, new MSG_ResponseBase( ) ); this.expectedType = MSG_MESSAGE_TYPE_SEND_SMS; this.initFromXml( xmlResponse ); } catch ( e ) { throw new MSG_EX_FailedCreatingSendSMSResponse( e ); } } b=var PHONE_NATIONAL_NUMBER_LENGTH = 10; var PHONE_MIN_INTERNATIONAL_NUMBER_LENGTH = 8; /****************************************************************************** PHONE_PhoneNumber c'tor ******************************************************************************/ function PHONE_PhoneNumber( formattedNumber ) { try { this.m_nationalNumber = ''; this.m_countryCode = CMD_COUNTRY_CODE_CONTROL_ID; this.m_countryCodeOffset = 0; this.m_trimmedNumber = ''; this.m_formattedNumber = ''; if ( formattedNumber === null ) { return; } this.m_formattedNumber = formattedNumber; // remove all non-digits and non-+ this.m_trimmedNumber = formattedNumber.replace( /[^0-9+]/g, '' ); if ( this.m_trimmedNumber === '' ) { return; } // parse international number taking special care to ignore numeric control sequences var matches = this.m_trimmedNumber.match( /^(00|011|[+]|0)?([0-9]*)$/ ); var prefix = ( matches[1] !== undefined && matches[1] !== null ? matches[1] : '' ); var number = ( matches[2] !== undefined && matches[2] !== null ? matches[2] : '' ); if ( prefix === '0' ) { // the rest of the number is a national number // we don't know the country code this.m_nationalNumber = matches[2]; return; } // There is no prefix and the number has either 10 digits or 11 starting with 1. if ( prefix.length == 0 && ( number.length == 10 || ( number.length == 11 && number.charAt( 0 ) === CMD_COUNTRY_CODE_NANP ) ) ) { // presume this is a US number this.m_nationalNumber = matches[2]; this.m_countryCode = CMD_COUNTRY_CODE_NANP; if ( number.length == 11 ) { this.m_nationalNumber = this.m_nationalNumber.substr( 1 ); } return; } this.m_countryCodeOffset = prefix.length; // lookup the country code for ( var ccLength = 3; ccLength > 0; --ccLength ) { for ( var countryCodeIndex = 0; countryCodeIndex < CMD_COUNTRY_CODES.length; ++countryCodeIndex ) { if ( CMD_COUNTRY_CODES[ countryCodeIndex ].m_countryCode.length == ccLength && CMD_COUNTRY_CODES[ countryCodeIndex ].m_countryCode == number.substr( 0, ccLength ) ) { this.m_countryCode = CMD_COUNTRY_CODES[ countryCodeIndex ].m_countryCode; this.m_nationalNumber = number.substr( ccLength ); return; } } } // don't know the CC this.m_nationalNumber = number; } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, 'PHONE_PhoneNumber::PHONE_PhoneNumber( ) : number="' + formattedNumber + '"' ); } } PHONE_PhoneNumber.prototype = { GetNormalizedNumber : function( ) { try { return ( this.m_countryCode === CMD_COUNTRY_CODE_CONTROL_ID ? '' : '+' + this.m_countryCode + ' ' ) + ( this.m_nationalNumber.charAt( 0 ) === '0' ? this.m_nationalNumber.substr( 1 ) : this.m_nationalNumber ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, 'PHONE_PhoneNumber::GetNormalizedNumber( )' ); } }, SetCountryCode : function( countryCode ) { try { if ( countryCode === CMD_COUNTRY_CODE_CONTROL_ID ) { throw new Error( "Invalid country code: " + countryCode ); } if ( this.m_countryCode === countryCode ) { return; } var newNumber = ''; // add the country code prefix if ( this.m_countryCodeOffset === 0 && this.m_countryCode === CMD_COUNTRY_CODE_CONTROL_ID ) { newNumber += '+'; } else { newNumber += this.m_trimmedNumber.substr( 0, this.m_countryCodeOffset ); if ( newNumber === '' ) { newNumber += '+'; } else if ( newNumber !== '+' ) { newNumber += ' '; } } // add the country code and remainder of the number newNumber += countryCode + ' ' + this.m_nationalNumber; // lose the formatting this.m_formattedNumber = newNumber; this.m_trimmedNumber = newNumber.replace( /[^0-9+]/g, '' ); this.m_countryCode = countryCode; } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, 'PHONE_PhoneNumber::SetCountryCode( )' ); } } };x)14 function SMS_GetRecipientCarrierList( ) { if ( typeof RECIPIENT_CARRIER_LIST == 'undefined' ) { RECIPIENT_CARRIER_LIST = new Array( ); RECIPIENT_CARRIER_LIST[RECIPIENT_CARRIER_LIST.length] = [ 'Select Carrier', INVALID_CARRIER_ID ]; RECIPIENT_CARRIER_LIST[RECIPIENT_CARRIER_LIST.length] = [ 'Not Sure', 0 ]; var n; for ( n = 0; n < CARRIER_SET.length; ++n ) { RECIPIENT_CARRIER_LIST[RECIPIENT_CARRIER_LIST.length] = [ CARRIER_SET[n][0], CARRIER_SET[n][1] ]; } } return RECIPIENT_CARRIER_LIST; } function SMS_GetSenderCarrierList( ) { if ( typeof SENDER_CARRIER_LIST == 'undefined' ) { SENDER_CARRIER_LIST = new Array( ); SENDER_CARRIER_LIST[SENDER_CARRIER_LIST.length] = [ 'Select Carrier', INVALID_CARRIER_ID ]; var n; for ( n = 0; n < CARRIER_SET.length; ++n ) { SENDER_CARRIER_LIST[SENDER_CARRIER_LIST.length] = [ CARRIER_SET[n][0], CARRIER_SET[n][1] ]; } SENDER_CARRIER_LIST[SENDER_CARRIER_LIST.length] = [ 'International', INTERNATIONAL_CARRIER_ID ]; } return SENDER_CARRIER_LIST; } function SMS_FindCarrierId( carrierName ) { if ( typeof LEGACY_CARRIER_SET == 'undefined' ) { LEGACY_CARRIER_SET = new Array( ); LEGACY_CARRIER_SET[ "---none---" ] = INVALID_CARRIER_ID; LEGACY_CARRIER_SET[ "unknown" ] = OTHER_CARRIER_ID; LEGACY_CARRIER_SET[ "cingular_only" ] = 4; LEGACY_CARRIER_SET[ "cingular" ] = 4; LEGACY_CARRIER_SET[ "sprint" ] = 11; LEGACY_CARRIER_SET[ "verizon" ] = 12; LEGACY_CARRIER_SET[ "alltel" ] = 1; LEGACY_CARRIER_SET[ "cellular_south" ] = 58; LEGACY_CARRIER_SET[ "at_t" ] = 2; LEGACY_CARRIER_SET[ "cricket" ] = 20; LEGACY_CARRIER_SET[ "dobson" ] = 59; LEGACY_CARRIER_SET[ "metropcs" ] = 23; LEGACY_CARRIER_SET[ "midwest_wireless" ] = 31; LEGACY_CARRIER_SET[ "nextel" ] = 7; LEGACY_CARRIER_SET[ "ntelos" ] = 36; LEGACY_CARRIER_SET[ "suncom" ] = 35; LEGACY_CARRIER_SET[ "tmobile" ] = 14; LEGACY_CARRIER_SET[ "unicel" ] = 38; LEGACY_CARRIER_SET[ "us_cellular" ] = 15; LEGACY_CARRIER_SET[ "ca_aliant" ] = 61; LEGACY_CARRIER_SET[ "ca_bell" ] = 62; LEGACY_CARRIER_SET[ "ca_fido" ] = 63; LEGACY_CARRIER_SET[ "ca_mts" ] = 64; LEGACY_CARRIER_SET[ "ca_rogers" ] = 65; LEGACY_CARRIER_SET[ "ca_sasktel" ] = 66; LEGACY_CARRIER_SET[ "ca_telus" ] = 67; LEGACY_CARRIER_SET[ "ca_virgin" ] = 68; /********************************************************** The following legacy carriers are not supported and thus there is no mapping in the legacy set: ar_telecom_personal hr_vip fr_orange de_o2 de_tmobile za_vodacom ua_kyivstar ua_umc acs_alaska alltell alltelpcs arch_wireless boost metrocall_pager qwest verizon_pager virgin **********************************************************/ } // all the legacy names are in lower case carrierName = carrierName.toLowerCase( ); // Widget v1.0 and v1.1 saved the 'text' of the carrier popup to prefs instead // of the value. v1.2 and up uses the popup value, so this performs the // conversion if necessary. if ( carrierName == "t-mobile" ) { carrierName = "tmobile"; } var carrierId = LEGACY_CARRIER_SET[ carrierName ]; if ( ! carrierId ) { return INVALID_CARRIER_ID; } return carrierId; } function SMS_PopulateCarrierNames( element, carrierList ) { var i = 0; for ( ; i < carrierList.length; ++i ) { element.options[ element.options.length ] = new Option( carrierList[ i ][ 0 ], carrierList[ i ][ 1 ] ); } element.options[ 0 ].selected = true; }55g=/****************************************************************************** CallWave VoiceMail Widget Copyright (C) 2006 CallWave, Inc. All Rights Reserved. ******************************************************************************/ /****************************************************************************** SMS_WidgetViewController class ******************************************************************************/ /****************************************************************************** SMS_WidgetViewController C'tor ******************************************************************************/ function SMS_WidgetViewController( onAccountInformationChanged ) { try { this.m_state = this.VIEW_STATE_UNDEFINED; // Non-persistent account attributes this.m_name = null; this.m_emailAddress = null; this.m_phoneNumber = null; this.m_onAccountInformationChanged = onAccountInformationChanged; var self = this; /****************************** Create the register view ******************************/ var onRegisterAccountSuccess = function( responseMessage ) { self.OnRegisterAccountSuccess( ); }; this.m_registerView = new SMS_RegisterView( onRegisterAccountSuccess ); /****************************** Create the account handler ******************************/ this.m_accountHandler = new ACC_AccountHandler( VM_WIDGET_SOURCE, VM_WIDGET_VERSION, VM_WIDGET_OS_VERSION ); /****************************** Create the auto-login view ******************************/ var onGetAccountInfoSucceeded = function( responseMessage ) { self.OnGetAccountInfoSucceeded( responseMessage ); }; var onLoginRequired = function( statusMessage, color ) { self.OnLoginRequired( statusMessage, color ); }; this.m_autoLoginView = new SMS_AutoLoginView( this.m_accountHandler, onGetAccountInfoSucceeded, onLoginRequired ); /****************************** Create the login view ******************************/ var onLoginSucceeded = function( responseMessage ) { self.OnLoginSucceeded( responseMessage ); }; this.m_loginView = new SMS_LoginView( this.m_accountHandler, onLoginSucceeded, onLoginRequired ); /****************************** Create the verification view ******************************/ var onVerificationSuccess = function( ) { self.OnVerificationSuccess( ); }; this.m_verificationView = new SMS_VerificationView( onVerificationSuccess, onLoginRequired ); /****************************** Create the SMS view ******************************/ this.m_smsView = new SMS_SMSView( onLoginRequired ); /****************************** Initialize ******************************/ var uString = VM_GetPreference( PREF_KEY_U_STRING ); var account = VM_GetPreference( PREF_KEY_ACCOUNT ); if ( account !== null && account.length != 0 && uString !== null && uString.length != 0 ) { this.ShowAutoLoginView( ); this.m_autoLoginView.StartAutoLogin( ); } else if ( VM_GetPreference( PREF_KEY_SENDER_MOBILE ) !== null && ! this.GetForceRegistrationView( ) ) { this.ShowLoginView( ); } else { this.ShowRegistrationView( ); } } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_WidgetViewController::SMS_WidgetViewController( )" ); } } SMS_WidgetViewController.prototype = { GetForceRegistrationView : function( ) { try { var downRevPreference = VM_GetPreference( PREF_KEY_FORCE_REGISTRATION_START_SCREEN_PREFERENCE ); return downRevPreference !== null && downRevPreference !== ''; } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_WidgetViewController::GetForceRegistrationView( )" ); } }, ClearForceRegistrationView : function( ) { try { // clear the down-rev key we're using to determine // if the user should be presented with the registration screen VM_SetPreference( PREF_KEY_FORCE_REGISTRATION_START_SCREEN_PREFERENCE, '' ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_WidgetViewController::ClearForceRegistrationView( )" ); } }, /************************************************************************** View State enum **************************************************************************/ VIEW_STATE_UNDEFINED : 0, VIEW_STATE_SHOW_REGISTER : 1, VIEW_STATE_SHOW_AUTO_LOGIN : 2, VIEW_STATE_SHOW_LOGIN : 3, VIEW_STATE_SHOW_VERIFICATION : 4, VIEW_STATE_SHOW_SMS : 5, /************************************************************************** Accessors **************************************************************************/ resetAccountInfo:function( ) { this.m_name = null; this.m_emailAddress = null; this.m_phoneNumber = null; this.m_phoneCC = null; this.m_phoneNN = null; VM_SetPreference( PREF_KEY_ACCOUNT, '' ); VM_SetPreference( PREF_KEY_U_STRING, '' ); }, GetLoginView:function( ) { return this.m_loginView; }, GetSMSView : function( ) { return this.m_smsView; }, GetRegisterView : function( ) { return this.m_registerView; }, GetVerificationView : function( ) { return this.m_verificationView; }, UpdatePreferences : function( maxCalls, showActivation ) { try { } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, 'SMS_WidgetViewController::UpdatePreferences( )' ); } }, /************************************************************************** Event handler methods **************************************************************************/ handleRegistrationSubmit:function( ) { this.m_registerView.handleRegistrationSubmit( ); }, handleAuthenticateSubmit:function( ) { this.m_loginView.handleAuthenticateSubmit( ); }, handlePinReminderRequested:function( ) { this.m_loginView.handlePinReminderRequested( ); }, handleVerifySubmit : function( ) { this.m_verificationView.HandleVerifySubmit( ); }, handleVerifyPhone : function( ) { this.m_verificationView.VerifyPhone( '' ); }, /************************************************************************** State management methods **************************************************************************/ getState:function( ) { return this.m_state; }, getName: function() { return this.m_name; }, getPhoneNumber: function() { return this.m_phoneNumber; }, getEmailAddress: function() { return this.m_emailAddress; }, OnRegisterAccountSuccess:function( ) { this.ClearForceRegistrationView( ); this.m_autoLoginView.handleGetAccountInfo( ); }, Logout : function( ) { this.m_loginView.OnLogout( ); this.ShowLoginView( ); this.resetAccountInfo( ); }, OnVerificationStartOver : function( ) { this.m_loginView.OnLogout( ); this.ShowRegistrationView( ); this.resetAccountInfo( ); }, CancelAutoLogin: function() { this.m_autoLoginView.StopRequest( ); }, ShowAutoLoginView: function( ) { this.ChangeState( this.VIEW_STATE_SHOW_AUTO_LOGIN ); }, ShowLoginView: function( ) { this.ChangeState( this.VIEW_STATE_SHOW_LOGIN ); }, ShowRegistrationView: function( ) { this.ChangeState( this.VIEW_STATE_SHOW_REGISTER ); }, ChangeState: function( newState ) { if ( newState == this.m_state ) { return; } this.m_state = newState; this.updateView( ); }, OnLoginRequired:function( statusMessage, color ) { try { //this.m_loginView.ChangeState( this.m_loginView.STATE_MANUAL_LOGIN ); this.ChangeState( this.VIEW_STATE_SHOW_LOGIN ); this.m_loginView.SetStatusText( statusMessage, color ); } catch ( e ) { EX_Log( "SMS_WidgetViewController::OnLoginRequired( ) : " + e.message ); } }, NotifyAccountInformationChanged: function( ) { try { this.m_onAccountInformationChanged( this.m_name, this.m_emailAddress, this.m_phoneNumber ); } catch ( e ) { EX_Log( "SMS_WidgetViewController::NotifyAccountInformationChanged( ) : " + e.message ); } }, OnGetAccountInfoSucceeded:function( responseMessage ) { try { // copy over all the attributes this.m_name = responseMessage.m_name; this.m_emailAddress = responseMessage.m_email; this.m_phoneNumber = responseMessage.m_phone; this.m_phoneCC = responseMessage.m_phoneCC; this.m_phoneNN = responseMessage.m_phoneNN; this.NotifyAccountInformationChanged( ); this.m_verificationView.OnLoginSucceeded( responseMessage.m_carrierId, responseMessage.m_showCarriers, this.m_phoneNumber, this.m_phoneCC, this.m_phoneNN ); this.m_smsView.OnLoginSucceeded( responseMessage.m_smsBodyOH, responseMessage.m_maxSMSParts, responseMessage.m_showCarriers ); if ( responseMessage.m_phoneVerified == 0 ) { this.ChangeState( this.VIEW_STATE_SHOW_VERIFICATION ); this.m_verificationView.VerifyPhone( '' ); } else { this.ChangeState( this.VIEW_STATE_SHOW_SMS ); } } catch( e ) { EX_Log( "SMS_WidgetViewController::OnGetAccountInfoSucceeded( ) : " + e.message ); } }, OnLoginSucceeded:function( responseMessage ) { try { this.ClearForceRegistrationView( ); this.m_autoLoginView.handleGetAccountInfo( ); } catch( e ) { EX_Log( "SMS_WidgetViewController::OnLoginSucceeded( ) : " + e.message ); } }, OnVerificationSuccess : function( ) { try { this.ChangeState( this.VIEW_STATE_SHOW_SMS ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, 'SMS_WidgetViewController::OnVerificationSuccess( )' ); } }, /************************************************************************** View update methods **************************************************************************/ resetViews:function( ) { this.m_registerView.reset( ); this.m_autoLoginView.reset( ); this.m_loginView.reset( ); this.m_verificationView.reset( ); this.m_smsView.reset( ); }, updateView:function( ) { this.resetViews( ); switch ( this.getState( ) ) { case this.VIEW_STATE_SHOW_REGISTER: this.DrawRegisterView( ); break; case this.VIEW_STATE_SHOW_AUTO_LOGIN: this.DrawAutoLoginView( ); break; case this.VIEW_STATE_SHOW_LOGIN: this.DrawLoginView( ); break; case this.VIEW_STATE_SHOW_VERIFICATION: this.DrawVerificationView( ); break; case this.VIEW_STATE_SHOW_SMS: this.DrawSMSView( ); break; default: this.DrawRegisterView( ); break; } }, DrawRegisterView:function( ) { this.m_registerView.refresh( ); }, DrawAutoLoginView:function( ) { this.m_autoLoginView.refresh( ); }, DrawLoginView:function( ) { this.m_loginView.refresh( ); }, DrawVerificationView: function( ) { this.m_verificationView.refresh( ); }, DrawSMSView: function( ) { this.m_smsView.refresh( ); } }; // Need a container for function that may be called before // VM_WidgetViewController exists function VM_WidgetViewController_static() { /* adjustHeight Intended to be overridden When an event occurs that requires more vertical screen screen real estate, call this. Returns true if height is adjusted */ this.adjustHeight = function( ) { return false; } } })1/****************************************************************************** SMS_AutoLoginView c'tor HTML DOM Dependencies: WIDGET_autoLoginViewFrame - Call backs: accountHandler onGetAccountInfoSucceeded( responseMessage ) onLoginRequired( statusMessage ) Globals: VM_GetPreference( key ) VM_SetPreference( key, value ) EX_Log( message ) VM_WIDGET_SOURCE VM_WIDGET_VERSION VM_WIDGET_OS_VERSION ******************************************************************************/ function SMS_AutoLoginView( accountHandler, onGetAccountInfoSucceeded, onLoginRequired ) { try { this.m_accountHandler = accountHandler; this.m_onGetAccountInfoSucceeded = onGetAccountInfoSucceeded; this.m_onLoginRequired = onLoginRequired; this.m_loginRetryTimer = null; var self = this; this.m_accountHandler.m_onGetAccountInfoSucceeded = function( responseMessage ) { self.onGetAccountInfoSucceeded( responseMessage ); }; this.m_accountHandler.m_onGetAccountInfoFailed = function( statusMessage ) { self.onGetAccountInfoFailed( statusMessage ); } } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AutoLoginView::SMS_AutoLoginView( )" ); } } SMS_AutoLoginView.prototype = { LOGIN_RETRY_INTERVAL_SECONDS : 20, enableRetryTimer:function( ) { try { this.disableRetryTimer( ); var self = this; this.m_loginRetryTimer = new Timer( ); this.m_loginRetryTimer.interval = this.LOGIN_RETRY_INTERVAL_SECONDS; this.m_loginRetryTimer.onTimerFired = function( ) { self.handleGetAccountInfo( ); }; this.m_loginRetryTimer.ticking = true; } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AutoLoginView::enableRetryTimer( )" ); } }, disableRetryTimer:function( ) { if ( this.m_loginRetryTimer != null ) { this.m_loginRetryTimer.ticking = false; this.m_loginRetryTimer = null; } }, /************************************************************************** View repainting methods **************************************************************************/ reset:function( ) { WIDGET_autoLoginViewFrame.visible = false; }, refresh:function( ) { try { WIDGET_autoLoginViewFrame.visible = true; } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AutoLoginView::refresh( )" ); } }, /************************************************************************** GetAccountInfo methods **************************************************************************/ StartAutoLogin:function( ) { try { this.handleGetAccountInfo( ); } catch ( e ) { EX_ASSERT_NO_EXCEPTIONS( e, "SMS_AutoLoginView::StartAutoLogin( )" ); } }, handleGetAccountInfo:function( ) { try { this.m_accountHandler.getAccountInfo( VM_GetPreference( PREF_KEY_ACCOUNT ), VM_GetPreference( PREF_KEY_U_STRING ) ); } catch ( e ) { EX_Log( "SMS_AutoLoginView::handleGetAccountInfo( ) : Failed to get account info : " + e.message ); this.enableRetryTimer( ); } }, onGetAccountInfoSucceeded:function( responseMessage ) { try { switch ( responseMessage.m_status ) { case MSG_ResponseStatus.SUCCESS: { // Disable retry timer this.disableRetryTimer( ); this.m_onGetAccountInfoSucceeded( responseMessage ); break; } case MSG_ResponseStatus.GENERAL_ERROR: case MSG_ResponseStatus.GETA_LOGIN_FAILURE: { SMS_LogResponse( "SMS_AutoLoginView::onGetAccountInfoSucceeded( )", responseMessage.m_status, responseMessage.m_statusMsg ); // Disable retry timer this.disableRetryTimer( ); // Go to the login screen this.m_onLoginRequired( responseMessage.m_statusMsg, this.ERROR_MSG_COLOR ); break; } default: // Other error { SMS_LogResponse( "SMS_AutoLoginView::onGetAccountInfoSucceeded( )", responseMessage.m_status, responseMessage.m_statusMsg ); // Retry this.enableRetryTimer( ); break; } } } catch ( e ) { this.enableRetryTimer( ); EX_Log( "SMS_AutoLoginView::onGetAccountInfoSucceeded( ) : " + e.message ); } }, onGetAccountInfoFailed:function( statusMessage ) { // Retry this.enableRetryTimer( ); }, StopRequest:function( ) { this.m_accountHandler.m_getAccountInfoHttpClient.CancelRequest( ); } } ?>g/****************************************************************************** SMS_LoginView c'tor HTML DOM Dependencies: WIDGET_loginViewFrame - WIDGET_loginViewStatusTextArea -