void CAboutDlg::OnShowWindow(BOOL bShow, UINT nStatus) { CString txt; CDialog::OnShowWindow(bShow, nStatus); txt = "Built "; txt = txt + __TIME__; txt = txt + " "; txt = txt + __DATE__; if (strlen(GetCompiler()) != 0) { txt = txt + " in "; txt = txt + GetCompiler(); } SetDlgItemText (IDC_STATIC3, txt); txt = "Using Gammu "; txt = txt + VERSION; SetDlgItemText (IDC_STATIC4, txt); txt = "Using MySQL library "; txt = txt + mysql_get_client_info(); SetDlgItemText (IDC_STATIC5, txt); txt = ""; if (strlen(GetOS()) != 0) { txt = "Run on "; txt = txt + GetOS(); } SetDlgItemText (IDC_STATIC6, txt); }
bool OS::UpdateStructureInformaion() { Info_System = *(InformationAboutSystem*)VirtualAlloc(0, sizeof(InformationAboutSystem), MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); DWORD InfoBuffer = MAX_INFO_SIZE; Info_System.Windows = (CHAR*)VirtualAlloc(0, MAX_WINDOWS_VNAME, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (NULL == Info_System.Windows) return false; if (false == GetOS(Info_System.Windows)) return false; Info_System.szUsername = (CHAR*)VirtualAlloc(0, MAX_INFO_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); if (NULL == Info_System.szUsername) return false; if (false == GetUserName(Info_System.szUsername, &InfoBuffer)) return false; GetLanguage(Info_System.szLanguage); Info_System.szLOCALE_IP = (char*)VirtualAlloc(0, MAX_IP_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); Info_System.szNET_IP = (char*)VirtualAlloc(0, MAX_IP_SIZE, MEM_COMMIT | MEM_RESERVE, PAGE_EXECUTE_READWRITE); GetComputerIp((char*)Info_System.szLOCALE_IP, LOCALE_IP); GetComputerIp((char*)Info_System.szNET_IP, NET_IP); this->Info_System.INTWindows = this->SetWinToUlong(this->Info_System.Windows); Info_System.WebCamera = this->IssetWebCam(); return true; }
//--------------------------------------------------------------------------- void __fastcall TTransBtnFormMain::TransparentButton6Click(TObject *Sender) { #if (TEST_NO_USE_DOWN>0) TransparentButton6->Down = !TransparentButton6->Down; #endif ShowMessage("OS is: " + GetOS() + "\n(Note that an OnClick event is generated when going down and when going up)"); }
void DSystemInfo::UpdateSystemInfo() { QString sysinfo; sysinfo += SL("System\n===========================\n"); sysinfo += SL("OS: %1\n").arg(GetOS()); sysinfo += SL("CPU: %1, %2 cores\n").arg(QString::fromStdString(cpu_info.Summarize())) .arg(QThread::idealThreadCount()); sysinfo += SL("\nDolphin\n===========================\n"); sysinfo += SL("SCM: branch %1, rev %2\n").arg(SC(scm_branch_str)).arg(SC(scm_rev_git_str)); sysinfo += SL("Compiled: %1, %2\n").arg(SL(__DATE__)).arg(SL(__TIME__)); sysinfo += SL("\nGUI\n===========================\n"); sysinfo += SL("Compiled for Qt: %1\n").arg(SL(QT_VERSION_STR)); sysinfo += SL("Running on Qt: %1").arg(SC(qVersion())); m_ui->txtSysInfo->setPlainText(sysinfo); }
void DSystemInfo::UpdateSystemInfo() { QString sysinfo; sysinfo += QStringLiteral("System\n===========================\n"); sysinfo += QStringLiteral("OS: %1\n").arg(GetOS()); sysinfo += QStringLiteral("CPU: %1, %2 logical processors\n") .arg(QString::fromStdString(cpu_info.Summarize())) .arg(QThread::idealThreadCount()); sysinfo += QStringLiteral("\nDolphin\n===========================\n"); sysinfo += QStringLiteral("SCM: branch %1, rev %2\n") .arg(QString::fromUtf8(scm_branch_str)) .arg(QString::fromUtf8(scm_rev_git_str)); sysinfo += QStringLiteral("\nGUI\n===========================\n"); sysinfo += QStringLiteral("Compiled for Qt: %1\n").arg(QStringLiteral(QT_VERSION_STR)); sysinfo += QStringLiteral("Running on Qt: %1").arg(QString::fromUtf8(qVersion())); m_ui->txtSysInfo->setPlainText(sysinfo); }
void CSkinBase::EnableTheming(BOOL bEnable) { if (GetOS() < SBOS_XP || bEnable == s_bThemingEnabled) return; static HMODULE hUXTheme = ::LoadLibrary("UXTheme.dll"); if (hUXTheme) { SETTHEMEAPPPROPERTIES SetThemeAppProperties = (SETTHEMEAPPPROPERTIES)GetProcAddress(hUXTheme, "SetThemeAppProperties"); if (SetThemeAppProperties) { SetThemeAppProperties(bEnable ? STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS | STAP_ALLOW_WEBCONTENT : 0); s_bThemingEnabled = bEnable; } } }
static SQL_Error SMSDSQL_NamedQuery(GSM_SMSDConfig * Config, const char *sql_query, GSM_SMSMessage *sms, const SQL_Var *params, SQL_result * res) { char buff[65536], *ptr, c, static_buff[8192]; char *buffer2, *end; const char *to_print, *q = sql_query; int int_to_print; int numeric; int n, argc = 0; struct GSM_SMSDdbobj *db = Config->db; if (params != NULL) { while (params[argc].type != SQL_TYPE_NONE) argc++; } ptr = buff; do { if (*q != '%') { *ptr++ = *q; continue; } c = *(++q); if( c >= '0' && c <= '9'){ n = strtoul(q, &end, 10) - 1; if (n < argc && n >= 0) { switch(params[n].type){ case SQL_TYPE_INT: ptr += sprintf(ptr, "%i", params[n].v.i); break; case SQL_TYPE_STRING: buffer2 = db->QuoteString(Config, params[n].v.s); memcpy(ptr, buffer2, strlen(buffer2)); ptr += strlen(buffer2); free(buffer2); break; default: SMSD_Log(DEBUG_ERROR, Config, "SQL: unknown type: %i (application bug) in query: `%s`", params[n].type, sql_query); return SQL_BUG; break; } } else { SMSD_Log(DEBUG_ERROR, Config, "SQL: wrong number of parameter: %i (max %i) in query: `%s`", n+1, argc, sql_query); return SQL_BUG; } q = end - 1; continue; } numeric = 0; to_print = NULL; switch (c) { case 'I': to_print = Config->Status->IMEI; break; case 'P': to_print = Config->PhoneID; break; case 'N': snprintf(static_buff, sizeof(static_buff), "Gammu %s, %s, %s", GAMMU_VERSION, GetOS(), GetCompiler()); to_print = static_buff; break; case 'A': to_print = Config->CreatorID; break; default: if (sms != NULL) { switch (c) { case 'R': EncodeUTF8(static_buff, sms->Number); to_print = static_buff; break; case 'F': EncodeUTF8(static_buff, sms->SMSC.Number); to_print = static_buff; break; case 'u': if (sms->UDH.Type != UDH_NoUDH) { EncodeHexBin(static_buff, sms->UDH.Text, sms->UDH.Length); to_print = static_buff; }else{ to_print = ""; } break; case 'x': int_to_print = sms->Class; numeric = 1; break; case 'c': to_print = GSM_SMSCodingToString(sms->Coding); break; case 't': int_to_print = sms->MessageReference; numeric = 1; break; case 'E': switch (sms->Coding) { case SMS_Coding_Unicode_No_Compression: case SMS_Coding_Default_No_Compression: EncodeHexUnicode(static_buff, sms->Text, UnicodeLength(sms->Text)); break; case SMS_Coding_8bit: EncodeHexBin(static_buff, sms->Text, sms->Length); break; default: *static_buff = '\0'; break; } to_print = static_buff; break; case 'T': switch (sms->Coding) { case SMS_Coding_Unicode_No_Compression: case SMS_Coding_Default_No_Compression: EncodeUTF8(static_buff, sms->Text); to_print = static_buff; break; default: to_print = ""; break; } break; case 'V': if (sms->SMSC.Validity.Format == SMS_Validity_RelativeFormat) { int_to_print = sms->SMSC.Validity.Relative; } else { int_to_print = -1; } numeric = 1; break; case 'C': SMSDSQL_Time2String(Config, Fill_Time_T(sms->SMSCTime), static_buff, sizeof(static_buff)); to_print = static_buff; break; case 'd': SMSDSQL_Time2String(Config, Fill_Time_T(sms->DateTime), static_buff, sizeof(static_buff)); to_print = static_buff; break; case 'e': int_to_print = sms->DeliveryStatus; numeric = 1; break; default: SMSD_Log(DEBUG_ERROR, Config, "SQL: uexpected char '%c' in query: %s", c, sql_query); return SQL_BUG; } /* end of switch */ } else { SMSD_Log(DEBUG_ERROR, Config, "Syntax error in query.. uexpected char '%c' in query: %s", c, sql_query); return SQL_BUG; } break; } /* end of switch */ if (numeric) { ptr += sprintf(ptr, "%i", int_to_print); } else if (to_print != NULL) { buffer2 = db->QuoteString(Config, to_print); memcpy(ptr, buffer2, strlen(buffer2)); ptr += strlen(buffer2); free(buffer2); } else { memcpy(ptr, "NULL", 4); ptr += 4; } } while (*(++q) != '\0'); *ptr = '\0'; return SMSDSQL_Query(Config, buff, res); }
int main(int argc, char **argv) { char text[256]; int i; #ifdef _WIN32 HMODULE hLib; WSADATA wsadata; WSAStartup(0x0202, &wsadata); InitUptimePerfCounter(); hLib = LoadLibrary("advapi32.dll"); if (hLib) lpfnRtlGenRandom = (_RtlGenRandom)GetProcAddress(hLib, "SystemFunction036"); #ifdef _DEBUG _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_CHECK_CRT_DF | _CRTDBG_ALLOC_MEM_DF); #endif #endif GetOS(text); printf("\n -- Phyros " BOT_VER " -- %s --\n\n", text); loadedtime = getuptime(); #ifndef _WIN32 SetPipeSignalHandler(); if (getuid() == 0) { printf("WARNING: should not be running as root!\n"); setuid(GetUidFromUsername("nobody")); } //////should set the group id instead so files can be modified at runtime #endif botpluser = malloc(sizeof(LUSER)); botpluser->access = 103; strcpy(botpluser->username, "the bot"); maintid = get_self_tid(); #ifndef _DEBUG SetSegvSignalHandler(); #endif tagbans[WCP_BACK] = RadixInit(); tagbans[WCP_FRONT] = RadixInit(); tagbans[WCP_BOTH] = RadixInit(); phrases = RadixInit(); cdkeys = VectorInit(8); //banqueue = malloc(BANQUEUE_INITIALSIZE * sizeof(char *)); //bqsize = BANQUEUE_INITIALSIZE; SetDefaultConfig(); LoadConfig(); LoadUsers(); LoadCDKeys(); GetRealms(); BlacklistLoad(); LoadPhrases(); CmdTreeInit(); LoadAccessModifications(); ParseCmdLine(argc, argv); for (i = 0; i != 3; i++) { if (!hashes[i][0]) { gstate |= GFS_USEBNLS; printf("WARNING: path for binary \'%s\' not set, falling back to BNLS checkrevision\n", hash_filenames[i]); break; } } if (gstate & GFS_CHECKUPDATES) { printf(" - checking %s%s for updates...\n", updatesite, updateverfile); printf("%s\n", updateresult[CheckUpdate(updatesite, updateverfile)]); } CreateAsyncTimer(); ptimertid = _CreateThread(PeriodicTimerWaitProc, NULL); AddPeriodicTimer(TIMER_NULLPKT, 10, NullPacketTimerProc); setjmp(jmpenv); ////////////////////////////////////////////TEST BATTERY////////////////////////////////////// /*ChatHandleChannel("Clan Blah", 0, 0); //ChatHandleJoin("loladfg", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf1aaaaaaaaaa", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf2bbbbbfffe", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf3", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf4", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf5", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf6", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf7", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf8", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladf9", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfa", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfb", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfc", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); ChatHandleJoin("loladfd", 0, 43, "PXES 0 0 0 0 0 PXES", 0, 0); */ /*printf("%x\n", FindTextInWildcards(tagbans, "asdfgdfg")); printf("%x\n", FindTextInWildcards(tagbans, "as[tg]gdfg")); printf("%x\n", FindTextInWildcards(tagbans, "asdfgdfg[tg]")); printf("%x\n", FindTextInWildcards(tagbans, "asdfgdfg")); printf("%x\n", FindPhraseban(phrases, "raiasdfdasdfzomgzasdfasdfasdfasdf")); printf("%x\n", FindPhraseban(phrases, "raiasdfgdfgbloop")); printf("%x\n", FindPhraseban(phrases, "bloo asfukdfgdfg zomg"));*/ ///////////////////////////////////////////////////////////////////////////////////////////// while (1) { fgets(text, sizeof(text), stdin); text[strlen(text) - 1] = 0; if (*(int16_t *)text == '//') CheckCommand(NULL, text, 0, 0); else QueueAdd(text, curbotinc()); } return 0; }
void HandleCmdReq(PLUSER pluser, char *text, int index) { char asdf[256], sdfg[256], timestamp[16], tmpuser[32]; char *tosend, *bigmem; int cmdi, i; time_t rawtime; void *timeinfo; void (*InviteResponse)(int, int); LPCHUSER pchuser; PLUSER tmppluser; char *temp, *arg2, chr; if ((gstate & GFS_LOCKED) && (pluser->access <= 100)) return; temp = strchr(text, ' '); if (temp) { *temp++ = 0; if ((pluser->access >= 100) && isnumstr(text)) { QueueAdd(temp, atoi(text)); return; } } lcase(text); //// justified cmdi = CmdGetIndex(hash((unsigned char *)text)); if (cmdi == -1 || strcmp(text, cmddesc[cmdi].string)) { if (pluser->access == 103) printf("\'%s\' invalid command!\n", text); return; } if (pluser->access < cmddesc[cmdi].access) return; tosend = NULL; bigmem = NULL; switch (cmdi) { case CMD_V: case CMD_VER: case CMD_VERSION: //*(int32_t *)0 = 0; ///for crash handle testing GetOS(sdfg); sprintf(asdf, pluser->access == 103 ? "Phyros " BOT_VER " [ %s ]" : "/me : : : Phyros " BOT_VER " [ %s ] : : : ", sdfg); tosend = asdf; break; case CMD_SAY: if (pluser->access < 100) *(--temp) = ' '; tosend = temp; break; case CMD_RUN: case CMD_LOUD: if (temp) _CreateThread(RunLoudProc, temp); break; case CMD_RUNQUIET: case CMD_QUIET: if (temp) _CreateThread(RunQuietProc, temp); break; case CMD_B: case CMD_BAN: HandleBUKUserCmd(pluser, temp, BTYPE_FBAN, index); break; case CMD_UU: sprintf(asdf, "/w %s You have been unbanned from %s.", temp, curchan); tosend = asdf; case CMD_UNBAN: case CMD_U: HandleBUKUserCmd(pluser, temp, BTYPE_UNBAN, index); break; case CMD_K: case CMD_KICK: HandleBUKUserCmd(pluser, temp, BTYPE_KICK, index); break; case CMD_A: case CMD_ACCESS: case CMD_WHOIS: case CMD_WHOAMI: if ((cmdi != CMD_WHOIS) && (!temp)) { tmppluser = pluser; } else { if (!temp) { tosend = asdf; break; } lcase(temp); /////justified RealmFix(temp, tmpuser, 0); //////ermm, is this a regression? tmppluser = HtGetItem(tmpuser, lusers, TL_LUSERS); } if (tmppluser) sprintf(asdf, "%s :: %d access", tmppluser->username, tmppluser->access); else sprintf(asdf, "%s not found in access database.", tmpuser); tosend = asdf; break; case CMD_CMDACCESS: case CMD_HELP: if (temp) { lcase(temp); ////justified i = CmdGetIndex(hash((unsigned char *)temp)); if (i == -1 || strcmp(temp, cmddesc[i].string)) { sprintf(asdf, "Command \'%s\' does not exist.", temp); tosend = asdf; } else { if (cmdi == CMD_CMDACCESS) { sprintf(asdf, "Command \'%s\' requires %d access.", temp, cmddesc[i].access); tosend = asdf; } else { tosend = HelpLookupCmdStr(i); } } tosend = asdf; } break; case CMD_CMDS: for (i = 0; i != ARRAYLEN(cmddesc); i++) { if (!temp || WildcardMatch(temp, cmddesc[i].string)) { printf("%s - access required: %d - %s", cmddesc[i].string, cmddesc[i].access, HelpLookupCmdUsage(i)); } } break; case CMD_ADD: *asdf = 0; HandleAddUserCmd(pluser, temp, asdf); if (*asdf) tosend = asdf; break; case CMD_REM: *asdf = 0; HandleRemoveUserCmd(pluser, temp, asdf); if (*asdf) tosend = asdf; break; case CMD_USERS: bigmem = HandleUsersCmd(); tosend = bigmem; break; case CMD_BL: case CMD_BLACKLIST: tosend = HandleBlacklistCmd(pluser, temp, asdf); if (!tosend) tosend = asdf; else bigmem = tosend; break; case CMD_SHITADD: case CMD_SA: chr = 'S'; goto over_ta; case CMD_TAGADD: case CMD_TA: chr = 'T'; over_ta: arg2 = strchr(temp, ' '); if (arg2) *arg2++ = 0; BlacklistAddToDB(text, chr, pluser->username, arg2, asdf); tosend = asdf; break; case CMD_SHITDEL: case CMD_SD: chr = 'S'; goto over_td; case CMD_TAGDEL: case CMD_TD: chr = 'T'; over_td: BlacklistRemoveFromDB(text, chr, asdf); tosend = asdf; break; case CMD_IPBAN: case CMD_IP: HandleBUKUserCmd(pluser, temp, BTYPE_IPBAN, index); break; case CMD_UNIPBAN: case CMD_UNIP: HandleBUKUserCmd(pluser, temp, BTYPE_UNIP, index); break; case CMD_SWEEP: // also add a wakechannel command to send everybody's name case CMD_SB: // sweep IDLE command (compare everybody in channel who didn't talk and kick) tosend = SweepStart(temp, asdf); break; case CMD_IPSWEEP: break; case CMD_IDLESWEEP: break; case CMD_P: case CMD_PING: if (temp) { if (*(int16_t *)temp == 's/') { Send0x15(index); break; } else { lcase(temp); //// justified RealmFix(temp, tmpuser, 0); pchuser = HtGetItem(tmpuser, users, TL_BNUSERS); } } else { pchuser = HtGetItem((pluser->access == 103) ? bot[curbotinc()]->realname : pluser->username, users, TL_BNUSERS); } if (pchuser) { sprintf(asdf, "%s's ping is %ums.", pchuser->username, pchuser->ping); tosend = asdf; } else { tosend = "Specified user cannot be found."; } break; case CMD_BANCOUNT: sprintf(asdf, "%u users have been banned.", bancount); tosend = asdf; break; case CMD_BANNED: bigmem = HandleBannedCmd(); tosend = bigmem; break; case CMD_J: case CMD_JOIN: sprintf(asdf, "/j %s", temp); tosend = asdf; break; case CMD_FJOIN: case CMD_FORCEJOIN: case CMD_FJ: InsertDWORD(0x02); InsertNTString(temp); SendPacket(0x0C, index); break; case CMD_HOME: sprintf(asdf, "/j %s", home); tosend = asdf; break; case CMD_CLOSE: case CMD_EXIT: case CMD_QUIT: exit(1); break; case CMD_LEAVE: SendPacket(0x10, index); break; case CMD_DAEMON: case CMD_HIDE: #ifdef _WIN32 ShowWindow(GetConsoleWindow(), SW_HIDE); #else #endif break; case CMD_SHOW: #ifdef _WIN32 ShowWindow(GetConsoleWindow(), SW_SHOW); #else #endif break; case CMD_CONNECT: if (temp) { i = atoi(temp); if (i < 0 || i >= numbots) break; ConnectBot(i); } else { for (i = 0; i != numbots; i++) { if (!bot[i]->connected) { ConnectBot(i); break; } } } break; case CMD_DISCONNECT: if (temp) { i = atoi(temp); if (i < 0 || i >= numbots) break; DisconnectBot(i, DISCN_GRACEFUL); } break; case CMD_RC: case CMD_RECONNECT: if (temp) { i = atoi(temp); if (i < 0 || i >= numbots) break; DisconnectBot(i, DISCN_GRACEFUL); ConnectBot(i); } break; case CMD_UPTIME: tosend = HandleUptimeCmd(asdf, temp, index); break; case CMD_CQ: cmdi = 0; for (i = 0; i != numbots; i++) cmdi += bot[i]->queue.count; sprintf(asdf, "Cleared %d queued items.", cmdi); tosend = asdf; case CMD_SCQ: QueueClearAll(); break; case CMD_CBQ: case CMD_SCBQ: break; case CMD_LW: case CMD_LASTWHISPER: if (lastwhisper.profile != -1) { sprintf(asdf, "Last whisper to profile %d was sent by %s: %s", lastwhisper.profile, lastwhisper.user, lastwhisper.message); tosend = asdf; } else { tosend = "No whispers received!"; } break; case CMD_DATE: case CMD_TIME: time(&rawtime); timeinfo = (void *)localtime(&rawtime); strftime(asdf, sizeof(asdf), (cmdi == CMD_DATE) ? "%m/%d/%Y" : "%I:%M:%S %p", (void *)timeinfo); tosend = asdf; break; case CMD_MOTD: if (pluser->access != 103) bot[index]->fstate |= BFS_EXTERNALREQ; InsertDWORD(0x3713); SendPacket(0x7C, index); break; case CMD_SETMOTD: if (temp) { sprintf(asdf, "/c motd %s", temp); QueueAdd(asdf, index); } break; case CMD_CLAN: if (pluser->access != 103) bot[index]->fstate |= BFS_EXTERNALREQ; Send0x7D(index); break; case CMD_CRANK: if (pluser->access != 103) bot[index]->fstate |= BFS_EXTERNALREQ; if (temp) { arg2 = strchr(temp, ' '); if (arg2) { *arg2++ = 0; Send0x7A(temp, (unsigned char)atoi(arg2), index); } } break; case CMD_INVITE: if (temp) { if (pluser->access != 103) bot[index]->fstate |= BFS_EXTERNALREQ; Send0x77(temp, index); } break; case CMD_TINVITES: ToggleGlobalFlag(temp, GFS_ACCEPTINVS, asdf, "%sing invintation requests.", "Accept", "Ignor"); tosend = asdf; break; case CMD_ACCEPT: case CMD_DECLINE: if (!bot[index]->invited.tag) { tosend = "No pending invitations."; } else { InviteResponse = (bot[index]->fstate & BFS_CREATEINV) ? Send0x72 : Send0x79; (*InviteResponse)((cmdi == CMD_ACCEPT) ? 'y' : 'n', temp ? atoi(temp) : index); sprintf(asdf, "%sed clan invitation.", (cmdi == CMD_ACCEPT) ? "Accept" : "Declin"); tosend = asdf; } break; case CMD_DP: break; case CMD_DDP: break; case CMD_CP: break; case CMD_AUTOCP: break; case CMD_GREET: break; case CMD_IDLE: break; case CMD_HALT: if (temp) { //lcase(temp); tmppluser = HtGetItem(temp, lusers, TL_LUSERS); if (tmppluser) { if (tmppluser->access < pluser->access) { if (tmppluser->flags & LUR_HALTED) { tmppluser->access = tmppluser->oacces; tmppluser->flags &= ~LUR_HALTED; } else { tmppluser->oacces = tmppluser->access; tmppluser->access = 1; tmppluser->flags |= LUR_HALTED; } sprintf(asdf, "User \'%s\' has been %shalted.", temp, (tmppluser->flags & LUR_HALTED) ? "" : "un"); tosend = asdf; } } } break; case CMD_SETTRIGGER: if (temp) { sprintf(asdf, "Trigger has been changed from \'%c\' to \'%c\'.", bot[index]->trigger, *temp); bot[index]->trigger = *temp; tosend = asdf; } break; case CMD_IGNPUB: if (temp) { temp = (((*(int16_t *)temp) | 0x2020) == 'on') ? "/o igpub" : "/o unigpub"; for (i = 1; i != numbots; i++) { if (bot[i]->connected) QueueAdd(temp, i); } ///////////////make it per profile, add ignpriv } break; case CMD_CLIENTBAN: //SetFlagAndValue(temp, GFS_CLIENTBAN, &clientban, asdf); break; case CMD_PHRASE: case CMD_PB: ////phraseban alias case CMD_PHRASEBAN: HandlePhraseCmd(pluser, temp, asdf); break; case CMD_PHRASEADD: break; case CMD_PHRASEDEL: break; case CMD_PINGBAN: break; case CMD_PLUGBAN: break; case CMD_INDEXBAN: break; case CMD_BANEVASION: break; case CMD_NUMBERSBAN: break; case CMD_ALTCAPSBAN: break; case CMD_BANNING: break; case CMD_LOADBAN: break; case CMD_WINBAN: SetFlagAndValue(temp, GFS_WINBAN, &ban_winlow, asdf, "Winban set to %d.", "Winban disabled."); tosend = asdf; break; case CMD_AUTOLOAD: break; case CMD_DESIGNATE: case CMD_OP: if (temp) { RealmFix(temp, tmpuser, 0); sprintf(asdf, "/designate %s", tmpuser); } else { sprintf(asdf, "/designate %s", pluser->username); } QueueAdd(asdf, index); if (cmdi == CMD_OP) RejoinChannel(index); break; case CMD_LOCKDOWN: break; case CMD_MASS: sprintf(asdf, "/j %s", temp); for (i = 0; i != numbots; i++) QueueAdd(asdf, i); break; case CMD_RJ: RejoinChannel(index); break; case CMD_PROFILES: bigmem = HandleProfilesCmd(); tosend = bigmem; break; case CMD_SETNAME: if (temp) { arg2 = strchr(temp, ' '); i = arg2 ? atoi(arg2 + 1) : 0; strncpy(bot[i]->username, temp, sizeof(bot[i]->username)); bot[i]->username[sizeof(bot[i]->username) - 1] = 0; sprintf(asdf, "Set new username for profile %d to %s.", i, bot[i]->username); tosend = asdf; /////////////////////////////////// } break; case CMD_SETPASS: if (temp) { arg2 = strchr(temp, ' '); i = arg2 ? atoi(arg2 + 1) : 0; strncpy(bot[i]->password, temp, sizeof(bot[i]->password)); bot[i]->password[sizeof(bot[i]->password) - 1] = 0; sprintf(asdf, "Set new password for profile %d.", i); tosend = asdf; /////////////////set permanently in config! } break; case CMD_RELOAD: tosend = HandleReloadCmd(temp); break; case CMD_CREMOVE: if (pluser->access != 103) bot[index]->fstate |= BFS_EXTERNALREQ; Send0x78(temp, index); break; case CMD_CHIEFTAIN: if (temp) { if (pluser->access != 103) bot[index]->fstate |= BFS_EXTERNALREQ; Send0x74(temp, index); } break; case CMD_MI: case CMD_MEMBERINFO: if (temp) { //weird, i never get a response... //if (pluser->access != 103) // bot[index]->fstate |= BFS_EXTERNALREQ; Send0x82(temp, index); } break; case CMD_CREATE: tosend = HandleClanCreateCommand(temp, index); break; case CMD_CHECKCLAN: if (temp) ////////////////////what about external requests? Send0x70(temp, index); break; case CMD_LOCK: ToggleGlobalFlag(temp, GFS_LOCKED, asdf, "Access has been %slocked.", "", "un"); tosend = asdf; break; case CMD_LOGGING: ToggleGlobalFlag(temp, GFS_LOGGING, asdf, "Logging %sabled.", "en", "dis"); tosend = asdf; break; case CMD_DISBAND: InsertDWORD(0x3713); SendPacket(0x73, index); break; case CMD_ERASE: tosend = HandleEraseCmd(temp); break; case CMD_PLGLOAD: break; case CMD_PLGSTAT: break; case CMD_PLGUNLOAD: break; case CMD_UPDATE: break; default: printf("Invalid command index %d (unimplemented)!\n", cmdi); } if (tosend) { if (pluser->access == 103) { GetTimeStamp(timestamp); printf("%s %s\n", timestamp, tosend); } else { QueueAdd(tosend, index); } } if (bigmem) free(bigmem); }
void DoBackup(int argc, char *argv[]) { GSM_Error error = ERR_NONE; int i, used; GSM_ToDoEntry ToDo; GSM_ToDoStatus ToDoStatus; GSM_CalendarEntry Calendar; GSM_Bitmap Bitmap; GSM_WAPBookmark Bookmark; GSM_Profile Profile; GSM_MultiWAPSettings Settings; GSM_SyncMLSettings SyncML; GSM_ChatSettings Chat; GSM_Ringtone Ringtone; GSM_SMSC SMSC; GSM_Backup Backup; GSM_NoteEntry Note; GSM_Backup_Info Info; GSM_FMStation FMStation; GSM_GPRSAccessPoint GPRSPoint; gboolean DoBackupPart; char buffer[GSM_MAX_INFO_LENGTH]; if (argc == 4 && strcasecmp(argv[3],"-yes") == 0) always_answer_yes = TRUE; GSM_ClearBackup(&Backup); GSM_GetBackupFormatFeatures(GSM_GuessBackupFormat(argv[2], FALSE),&Info); sprintf(Backup.Creator,"Gammu %s",VERSION); if (strlen(GetOS()) != 0) { strcat(Backup.Creator+strlen(Backup.Creator),", "); strcat(Backup.Creator+strlen(Backup.Creator),GetOS()); } if (strlen(GetCompiler()) != 0) { strcat(Backup.Creator+strlen(Backup.Creator),", "); strcat(Backup.Creator+strlen(Backup.Creator),GetCompiler()); } signal(SIGINT, interrupt); fprintf(stderr, "%s\n", _("Press Ctrl+C to break...")); GSM_Init(TRUE); if (Info.UseUnicode) { Info.UseUnicode=answer_yes("%s", _("Use Unicode subformat of backup file?")); } if (Info.DateTime) { GSM_GetCurrentDateTime (&Backup.DateTime); Backup.DateTimeAvailable=TRUE; } if (Info.Model) { error=GSM_GetManufacturer(gsm, Backup.Model); Print_Error(error); strcat(Backup.Model," "); error=GSM_GetModel(gsm, buffer); strcat(Backup.Model, buffer); if (GSM_GetModelInfo(gsm)->model[0]!=0) { strcat(Backup.Model," ("); strcat(Backup.Model,GSM_GetModelInfo(gsm)->model); strcat(Backup.Model,")"); } strcat(Backup.Model," "); error=GSM_GetFirmware(gsm, buffer, NULL, NULL); strcat(Backup.Model,buffer); } if (Info.IMEI) { error=GSM_GetIMEI(gsm, Backup.IMEI); if (error != ERR_NOTSUPPORTED) { Print_Error(error); } else { Backup.IMEI[0] = 0; } } printf("\n"); if (Info.PhonePhonebook) { printf("%s\n", _("Checking phone phonebook")); ReadPhonebook(Backup.PhonePhonebook, MEM_ME, _("Backup phone phonebook?"), GSM_BACKUP_MAX_PHONEPHONEBOOK); } if (Info.SIMPhonebook) { printf("%s\n", _("Checking SIM phonebook")); ReadPhonebook(Backup.SIMPhonebook, MEM_SM, _("Backup SIM phonebook?"), GSM_BACKUP_MAX_SIMPHONEBOOK); } DoBackupPart = FALSE; if (Info.Calendar) { printf("%s\n", _("Checking phone calendar")); Calendar.Location = 0; error=GSM_GetNextCalendar(gsm,&Calendar,TRUE); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone calendar notes?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); while (error == ERR_NONE) { if (used < GSM_MAXCALENDARTODONOTES) { Backup.Calendar[used] = malloc(sizeof(GSM_CalendarEntry)); if (Backup.Calendar[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Calendar[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_MAXCALENDARTODONOTES"); printf("\n"); break; } *Backup.Calendar[used]=Calendar; used ++; error=GSM_GetNextCalendar(gsm,&Calendar,FALSE); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.ToDo) { printf("%s\n", _("Checking phone todos")); error=GSM_GetToDoStatus(gsm,&ToDoStatus); if (error == ERR_NONE && ToDoStatus.Used != 0) { if (answer_yes(" %s", _("Backup phone todos?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; ToDo.Location = 0; error=GSM_GetNextToDo(gsm,&ToDo,TRUE); while (error == ERR_NONE) { if (used < GSM_MAXCALENDARTODONOTES) { Backup.ToDo[used] = malloc(sizeof(GSM_ToDoEntry)); if (Backup.ToDo[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.ToDo[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_MAXCALENDARTODONOTES"); printf("\n"); break; } *Backup.ToDo[used]=ToDo; used ++; error=GSM_GetNextToDo(gsm,&ToDo,FALSE); fprintf(stderr, "\r "); fprintf(stderr, "%s ", _("Reading:")); fprintf(stderr, _("%i percent"), used * 100 / ToDoStatus.Used); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); } DoBackupPart = FALSE; if (Info.Note) { printf("%s\n", _("Checking phone notes")); Note.Location = 0; error=GSM_GetNextNote(gsm,&Note,TRUE); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone notes?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_NOTE) { Backup.Note[used] = malloc(sizeof(GSM_NoteEntry)); if (Backup.Note[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Note[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_NOTE"); printf("\n"); break; } *Backup.Note[used]=Note; used ++; error=GSM_GetNextNote(gsm,&Note,FALSE); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.CallerLogos) { printf("%s\n", _("Checking phone caller logos")); Bitmap.Type = GSM_CallerGroupLogo; Bitmap.Location = 1; error=GSM_GetBitmap(gsm,&Bitmap); if (error == ERR_NONE) { if (answer_yes(" %s", _("Backup phone caller groups and logos?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; used = 0; while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_CALLER) { Backup.CallerLogos[used] = malloc(sizeof(GSM_Bitmap)); if (Backup.CallerLogos[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.CallerLogos[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_CALLER"); printf("\n"); break; } *Backup.CallerLogos[used] = Bitmap; used ++; Bitmap.Location = used + 1; error=GSM_GetBitmap(gsm,&Bitmap); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.SMSC) { printf("%s\n", _("Checking SIM SMS profiles")); if (answer_yes(" %s", _("Backup SIM SMS profiles?"))) DoBackupPart = TRUE; } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); while (TRUE) { SMSC.Location = used + 1; error = GSM_GetSMSC(gsm,&SMSC); if (error != ERR_NONE) break; if (used < GSM_BACKUP_MAX_SMSC) { Backup.SMSC[used] = malloc(sizeof(GSM_SMSC)); if (Backup.SMSC[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SMSC[used + 1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_SMSC"); printf("\n"); break; } *Backup.SMSC[used]=SMSC; used++; fprintf(stderr, "*"); } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.StartupLogo) { printf("%s\n", _("Checking phone startup text")); Bitmap.Type = GSM_WelcomeNote_Text; error = GSM_GetBitmap(gsm,&Bitmap); if (error == ERR_NONE) { if (answer_yes(" %s", _("Backup phone startup logo/text?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { Backup.StartupLogo = malloc(sizeof(GSM_Bitmap)); if (Backup.StartupLogo == NULL) Print_Error(ERR_MOREMEMORY); *Backup.StartupLogo = Bitmap; if (Bitmap.Text[0]==0 && Bitmap.Text[1]==0) { Bitmap.Type = GSM_StartupLogo; error = GSM_GetBitmap(gsm,&Bitmap); if (error == ERR_NONE) *Backup.StartupLogo = Bitmap; } } DoBackupPart = FALSE; if (Info.OperatorLogo) { printf("%s\n", _("Checking phone operator logo")); Bitmap.Type = GSM_OperatorLogo; error=GSM_GetBitmap(gsm,&Bitmap); if (error == ERR_NONE) { if (strcmp(Bitmap.NetworkCode,"000 00")!=0) { if (answer_yes(" %s", _("Backup phone operator logo?"))) DoBackupPart = TRUE; } } } if (DoBackupPart) { Backup.OperatorLogo = malloc(sizeof(GSM_Bitmap)); if (Backup.OperatorLogo == NULL) Print_Error(ERR_MOREMEMORY); *Backup.OperatorLogo = Bitmap; } DoBackupPart = FALSE; if (Info.WAPBookmark) { printf("%s\n", _("Checking phone WAP bookmarks")); Bookmark.Location = 1; error=GSM_GetWAPBookmark(gsm,&Bookmark); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone WAP bookmarks?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_WAPBOOKMARK) { Backup.WAPBookmark[used] = malloc(sizeof(GSM_WAPBookmark)); if (Backup.WAPBookmark[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.WAPBookmark[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_WAPBOOKMARK"); printf("\n"); break; } *Backup.WAPBookmark[used]=Bookmark; used ++; Bookmark.Location = used+1; error=GSM_GetWAPBookmark(gsm,&Bookmark); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.WAPSettings) { printf("%s\n", _("Checking phone WAP settings")); Settings.Location = 1; error=GSM_GetWAPSettings(gsm,&Settings); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone WAP settings?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_WAPSETTINGS) { Backup.WAPSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); if (Backup.WAPSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.WAPSettings[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_WAPSETTINGS"); printf("\n"); break; } *Backup.WAPSettings[used]=Settings; used ++; Settings.Location = used+1; error=GSM_GetWAPSettings(gsm,&Settings); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.MMSSettings) { printf("%s\n", _("Checking phone MMS settings")); Settings.Location = 1; error=GSM_GetMMSSettings(gsm,&Settings); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone MMS settings?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_MMSSETTINGS) { Backup.MMSSettings[used] = malloc(sizeof(GSM_MultiWAPSettings)); if (Backup.MMSSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.MMSSettings[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_MMSSETTINGS"); printf("\n"); break; } *Backup.MMSSettings[used]=Settings; used ++; Settings.Location = used+1; error=GSM_GetMMSSettings(gsm,&Settings); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.ChatSettings) { printf("%s\n", _("Checking phone Chat settings")); Chat.Location = 1; error=GSM_GetChatSettings(gsm,&Chat); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone Chat settings?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_CHATSETTINGS) { Backup.ChatSettings[used] = malloc(sizeof(GSM_ChatSettings)); if (Backup.ChatSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.ChatSettings[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_CHATSETTINGS"); printf("\n"); break; } *Backup.ChatSettings[used]=Chat; used ++; Chat.Location = used+1; error=GSM_GetChatSettings(gsm,&Chat); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.SyncMLSettings) { printf("%s\n", _("Checking phone SyncML settings")); SyncML.Location = 1; error=GSM_GetSyncMLSettings(gsm,&SyncML); if (error==ERR_NONE) { if (answer_yes(" %s", _("Backup phone SyncML settings?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); while (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_SYNCMLSETTINGS) { Backup.SyncMLSettings[used] = malloc(sizeof(GSM_SyncMLSettings)); if (Backup.SyncMLSettings[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.SyncMLSettings[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_SYNCMLSETTINGS"); printf("\n"); break; } *Backup.SyncMLSettings[used]=SyncML; used ++; SyncML.Location = used+1; error=GSM_GetSyncMLSettings(gsm,&SyncML); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.Ringtone) { printf("%s\n", _("Checking phone user ringtones")); Ringtone.Location = 1; Ringtone.Format = 0; error=GSM_GetRingtone(gsm,&Ringtone,FALSE); if (error==ERR_EMPTY || error == ERR_NONE) { if (answer_yes(" %s", _("Backup phone user ringtones?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; i = 1; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE || error == ERR_EMPTY) { if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_RINGTONES) { Backup.Ringtone[used] = malloc(sizeof(GSM_Ringtone)); if (Backup.Ringtone[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Ringtone[used+1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_RINGTONES"); printf("\n"); break; } *Backup.Ringtone[used]=Ringtone; used ++; } i++; Ringtone.Location = i; Ringtone.Format = 0; error=GSM_GetRingtone(gsm,&Ringtone,FALSE); fprintf(stderr, "*"); if (gshutdown) { GSM_Terminate(); Terminate(4); } } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.Profiles) { printf("%s\n", _("Checking phone profiles")); Profile.Location = 1; error = GSM_GetProfile(gsm,&Profile); if (error == ERR_NONE) { if (answer_yes(" %s", _("Backup phone profiles?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; fprintf(stderr, LISTFORMAT, _("Reading")); while (TRUE) { Profile.Location = used + 1; error = GSM_GetProfile(gsm,&Profile); if (error != ERR_NONE) break; if (used < GSM_BACKUP_MAX_PROFILES) { Backup.Profiles[used] = malloc(sizeof(GSM_Profile)); if (Backup.Profiles[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.Profiles[used + 1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_PROFILES"); printf("\n"); break; } *Backup.Profiles[used]=Profile; used++; fprintf(stderr, "*"); } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.FMStation) { printf("%s\n", _("Checking phone FM radio stations")); FMStation.Location = 1; error = GSM_GetFMStation(gsm,&FMStation); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes(" %s", _("Backup phone FM radio stations?"))) DoBackupPart=TRUE; } } if (DoBackupPart) { used = 0; i = 1; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE || error == ERR_EMPTY) { error = GSM_GetFMStation(gsm,&FMStation); if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_FMSTATIONS) { Backup.FMStation[used] = malloc(sizeof(GSM_FMStation)); if (Backup.FMStation[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.FMStation[used + 1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_FMSTATIONS"); printf("\n"); break; } *Backup.FMStation[used]=FMStation; used++; } i++; FMStation.Location = i; fprintf(stderr, "*"); } fprintf(stderr, "\n"); fflush(stderr); } DoBackupPart = FALSE; if (Info.GPRSPoint) { printf("%s\n", _("Checking phone GPRS access points")); GPRSPoint.Location = 1; error = GSM_GetGPRSAccessPoint(gsm,&GPRSPoint); if (error == ERR_NONE || error == ERR_EMPTY) { if (answer_yes(" %s", _("Backup phone GPRS access points?"))) DoBackupPart = TRUE; } } if (DoBackupPart) { used = 0; i = 1; fprintf(stderr, LISTFORMAT, _("Reading")); error = ERR_NONE; while (error == ERR_NONE || error == ERR_EMPTY) { error = GSM_GetGPRSAccessPoint(gsm,&GPRSPoint); if (error == ERR_NONE) { if (used < GSM_BACKUP_MAX_GPRSPOINT) { Backup.GPRSPoint[used] = malloc(sizeof(GSM_GPRSAccessPoint)); if (Backup.GPRSPoint[used] == NULL) Print_Error(ERR_MOREMEMORY); Backup.GPRSPoint[used + 1] = NULL; } else { printf("\n "); printf(_("Only part of data saved, please increase %s.") , "GSM_BACKUP_MAX_GPRSPOINT"); printf("\n"); break; } *Backup.GPRSPoint[used]=GPRSPoint; used++; } i++; GPRSPoint.Location = i; fprintf(stderr, "*"); } fprintf(stderr, "\n"); fflush(stderr); } GSM_Terminate(); GSM_SaveBackupFile(argv[2], &Backup, GSM_GuessBackupFormat(argv[2], Info.UseUnicode)); GSM_FreeBackup(&Backup); }
#define LWA_COLORKEY 0x00000001 #define LWA_ALPHA 0x00000002 #define ULW_COLORKEY 0x00000001 #define ULW_ALPHA 0x00000002 #define ULW_OPAQUE 0x00000004 #endif ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// int CSkinBase::s_nOSVer = -1; PFNTRANSPARENTBLT CSkinBase::s_pfnFastTransparentBlt = NULL; PFNGRADIENTFILL CSkinBase::s_pfnFastGradientFill = NULL; BOOL CSkinBase::s_bThemingEnabled = (GetOS() >= SBOS_XP); // don't use fast trasparent blt on win95/98 because msimg32.dll has a resource leak BOOL CSkinBase::s_bSupportsFastTransparentBlt = (GetOS() < SBOS_ME) ? FALSE : -1; BOOL CSkinBase::s_bSupportsFastGradientFill = (GetOS() < SBOS_ME) ? FALSE : -1; CSkinBase::CSkinBase() { } CSkinBase::~CSkinBase() { } int CSkinBase::GetOS() {
GSM_Error GSM_InitConnection_Log(GSM_StateMachine *s, int ReplyNum, GSM_Log_Function log_function, void *user_data) { GSM_Error error; GSM_DateTime current_time; int i; for (i=0;i<s->ConfigNum;i++) { s->CurrentConfig = &s->Config[i]; /* Skip non configured sections */ if (s->CurrentConfig->Connection == NULL) { smprintf_level(s, D_ERROR, "[Empty section - %d]\n", i); continue; } s->Speed = 0; s->ReplyNum = ReplyNum; s->Phone.Data.ModelInfo = GetModelData(s, "unknown", NULL, NULL); s->Phone.Data.Manufacturer[0] = 0; s->Phone.Data.Model[0] = 0; s->Phone.Data.Version[0] = 0; s->Phone.Data.VerDate[0] = 0; s->Phone.Data.VerNum = 0; s->Phone.Data.StartInfoCounter = 0; s->Phone.Data.SentMsg = NULL; s->Phone.Data.HardwareCache[0] = 0; s->Phone.Data.ProductCodeCache[0] = 0; s->Phone.Data.EnableIncomingCall = FALSE; s->Phone.Data.EnableIncomingSMS = FALSE; s->Phone.Data.EnableIncomingCB = FALSE; s->Phone.Data.EnableIncomingUSSD = FALSE; s->User.UserReplyFunctions = NULL; s->User.IncomingCall = NULL; s->User.IncomingSMS = NULL; s->User.IncomingCB = NULL; s->User.IncomingUSSD = NULL; s->User.SendSMSStatus = NULL; s->LockFile = NULL; s->opened = FALSE; s->Phone.Functions = NULL; s->di = GSM_none_debug; s->di.use_global = s->CurrentConfig->UseGlobalDebugFile; if (!s->di.use_global) { GSM_SetDebugFunction(log_function, user_data, &s->di); GSM_SetDebugLevel(s->CurrentConfig->DebugLevel, &s->di); error = GSM_SetDebugFile(s->CurrentConfig->DebugFile, &s->di); if (error != ERR_NONE) { GSM_LogError(s, "Init:GSM_SetDebugFile" , error); return error; } } smprintf_level(s, D_ERROR, "[Gammu - %s built %s %s using %s]\n", GAMMU_VERSION, __TIME__, __DATE__, GetCompiler() ); StripSpaces(s->CurrentConfig->Connection); StripSpaces(s->CurrentConfig->Model); StripSpaces(s->CurrentConfig->Device); smprintf_level(s, D_ERROR, "[Connection - \"%s\"]\n", s->CurrentConfig->Connection); smprintf_level(s, D_ERROR, "[Connection index - %d]\n", i); smprintf_level(s, D_ERROR, "[Model type - \"%s\"]\n", s->CurrentConfig->Model); smprintf_level(s, D_ERROR, "[Device - \"%s\"]\n", s->CurrentConfig->Device); if (strlen(GetOS()) != 0) { smprintf_level(s, D_ERROR, "[Running on - %s]\n", GetOS()); } if (GSM_GetDI(s)->dl == DL_BINARY) { smprintf(s,"%c",((unsigned char)strlen(GAMMU_VERSION))); smprintf(s,"%s",GAMMU_VERSION); } error = GSM_RegisterAllConnections(s, s->CurrentConfig->Connection); if (error != ERR_NONE) { GSM_LogError(s, "Init:GSM_RegisterAllConnections" , error); return error; } autodetect: /* Model auto */ /* Try to guess correct driver based on model */ if (s->CurrentConfig->Model[0] == 0 && s->ConnectionType != GCT_NONE && s->ConnectionType != GCT_IRDAOBEX && s->ConnectionType != GCT_BLUEOBEX && s->ConnectionType != GCT_BLUEGNAPBUS && s->ConnectionType != GCT_IRDAGNAPBUS && s->ConnectionType != GCT_BLUES60) { error = GSM_TryGetModel(s); /* Fall back to other configuraitons if the device is not existing (or similar error) */ if ((i != s->ConfigNum - 1) && ( (error == ERR_DEVICEOPENERROR) || (error == ERR_DEVICELOCKED) || (error == ERR_DEVICENOTEXIST) || (error == ERR_DEVICEBUSY) || (error == ERR_DEVICENOPERMISSION) || (error == ERR_DEVICENODRIVER) || (error == ERR_DEVICENOTWORK))) { GSM_CloseConnection(s); continue; } if (error != ERR_NONE) { GSM_LogError(s, "Init:GSM_TryGetModel" , error); return error; } } /* Switching to "correct" module */ error = GSM_RegisterAllPhoneModules(s); /* If user selected soemthing which is not supported, try autodetection */ if (s->CurrentConfig->Model[0] != 0 && error == ERR_UNKNOWNMODELSTRING) { smprintf(s, "Configured model %s is not known, retrying with autodetection!\n", s->CurrentConfig->Model); s->CurrentConfig->Model[0] = 0; goto autodetect; } if (error != ERR_NONE) { GSM_LogError(s, "Init:GSM_RegisterAllPhoneModules" , error); return error; } /* We didn't open device earlier ? Make it now */ if (!s->opened) { error = GSM_OpenConnection(s); if ((i != s->ConfigNum - 1) && ( (error == ERR_DEVICEOPENERROR) || (error == ERR_DEVICELOCKED) || (error == ERR_DEVICENOTEXIST) || (error == ERR_DEVICEBUSY) || (error == ERR_DEVICENOPERMISSION) || (error == ERR_DEVICENODRIVER) || (error == ERR_DEVICENOTWORK))) { GSM_CloseConnection(s); continue; } if (error != ERR_NONE) { GSM_LogError(s, "Init:GSM_OpenConnection" , error); return error; } } /* Initialize phone layer */ error=s->Phone.Functions->Initialise(s); if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) { GSM_CloseConnection(s); continue; } if (error != ERR_NONE) { GSM_LogError(s, "Init:Phone->Initialise" , error); return error; } if (s->CurrentConfig->StartInfo) { s->Phone.Functions->ShowStartInfo(s,TRUE); s->Phone.Data.StartInfoCounter = 30; } if (s->CurrentConfig->SyncTime) { GSM_GetCurrentDateTime (¤t_time); s->Phone.Functions->SetDateTime(s,¤t_time); } /* For debug it's good to have firmware and real model version and manufacturer */ error=s->Phone.Functions->GetManufacturer(s); if (error == ERR_TIMEOUT && i != s->ConfigNum - 1) { GSM_CloseConnection(s); continue; } if (error != ERR_NONE && error != ERR_NOTSUPPORTED) { GSM_LogError(s, "Init:Phone->GetManufacturer" , error); return error; } error=s->Phone.Functions->GetModel(s); if (error != ERR_NONE && error != ERR_NOTSUPPORTED) { GSM_LogError(s, "Init:Phone->GetModel" , error); return error; } error=s->Phone.Functions->GetFirmware(s); if (error != ERR_NONE && error != ERR_NOTSUPPORTED) { GSM_LogError(s, "Init:Phone->GetFirmware" , error); return error; } smprintf(s,"[Connected]\n"); return ERR_NONE; } return ERR_UNCONFIGURED; }