// xdaunlock.cpp : Defines the class behaviors for the application. // #include "stdafx.h" #include "xdaunlock.h" #include "xdaunlockDlg.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ///////////////////////////////////////////////////////////////////////////// // CXdaUnlockApp BEGIN_MESSAGE_MAP(CXdaUnlockApp, CWinApp) //{{AFX_MSG_MAP(CXdaUnlockApp) // NOTE - the ClassWizard will add and remove mapping macros here. // DO NOT EDIT what you see in these blocks of generated code! //}}AFX_MSG END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CXdaUnlockApp construction CXdaUnlockApp::CXdaUnlockApp() : CWinApp() { // TODO: add construction code here, m_bBeQuiet= false; m_bRunDialog= false; // Place all significant initialization in InitInstance } ///////////////////////////////////////////////////////////////////////////// // The one and only CXdaUnlockApp object CXdaUnlockApp theApp; ///////////////////////////////////////////////////////////////////////////// // CXdaUnlockApp initialization BOOL CXdaUnlockApp::InitInstance() { // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. if (m_bRunDialog) { CXdaUnlockDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } } else if (m_bLockPhone) DoBasicLock(); else DoBasicUnlock(); // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; } BOOL CXdaUnlockApp::InitApplication() { if (_tcscmp(this->m_lpCmdLine, L"-d")==0) m_bRunDialog= true; else if (_tcscmp(this->m_lpCmdLine, L"-q")==0) m_bBeQuiet= true; else if (_tcsncmp(this->m_lpCmdLine, L"-l", 2)==0) { m_bLockPhone= true; m_sLockCode= this->m_lpCmdLine+2; } return true; } void CXdaUnlockApp::DoBasicLock() { Unlocker m_unlocker; m_unlocker.LockPhone(m_sLockCode); } void CXdaUnlockApp::DoBasicUnlock() { Unlocker m_unlocker; TCHAR *szTitle= L"XDA Unlock"; CString code; if (!m_unlocker.GetUnlockCode(code)) { if (!m_bBeQuiet) MessageBox(NULL, L"error getting unlock code", szTitle, MB_OK|MB_ICONERROR); return; } if (code.Compare(L"FFFFFFFF")==0) { if (!m_bBeQuiet) MessageBox(NULL, L"Your phone is already unlocked", szTitle, MB_OK|MB_ICONINFORMATION); return; } if (IDYES==MessageBox(NULL, L"Your phone appears to be 'SIMlocked'. This means it is only useable with one or a few cellular providers. " \ L"Would you like to rectify this now?", szTitle, MB_YESNO|MB_ICONQUESTION)) { if (!m_unlocker.DoUnlock(code)) { MessageBox(NULL, L"An error occured while unlocking your phone. Unlocking failed.", szTitle, MB_OK|MB_ICONERROR); return; } MessageBox(NULL, L"Your phone has been successfully unlocked.", szTitle, MB_OK|MB_ICONINFORMATION); } }