bool EditNamePage::begin() { if ( m_user ) { String buffer = getStaticString(SST_CHANGE_NAME) ; buffer += ":"; lcdDevice.print(buffer); controller.setInputForText(buffer.length() + 1, m_user->name, MAX_USER_NAME_LENGTH); controller.setHelpText(getStaticString(SST_CHANGE_NAME_HELP)); return true; } return false; }
static void propertyDocCopy(BoxedProperty* prop, Box* fget) { assert(prop); assert(fget); Box* get_doc; static BoxedString* doc_str = getStaticString("__doc__"); try { get_doc = getattrInternal<ExceptionStyle::CXX>(fget, doc_str); } catch (ExcInfo e) { if (!e.matches(Exception)) { throw e; } e.clear(); get_doc = NULL; } if (get_doc) { if (prop->cls == property_cls) { Py_XDECREF(prop->prop_doc); prop->prop_doc = get_doc; } else { /* If this is a property subclass, put __doc__ in dict of the subclass instance instead, otherwise it gets shadowed by __doc__ in the class's dict. */ setattr(prop, doc_str, get_doc); } prop->getter_doc = true; } }
void addToSysArgv(const char* str) { static BoxedString* argv_str = getStaticString("argv"); Box* sys_argv = sys_module->getattr(argv_str); assert(sys_argv); assert(sys_argv->cls == list_cls); listAppendInternalStolen(sys_argv, boxString(str)); }
int __cdecl CMsnProto::AuthRequest(HANDLE hContact, const TCHAR* szMessage) { if (msnLoggedIn) { char email[MSN_MAX_EMAIL_LEN]; if (getStaticString(hContact, "e-mail", email, sizeof(email))) return 1; char* szMsg = mir_utf8encodeT(szMessage); // int netId = Lists_GetNetId(email); // if (netId == NETID_UNKNOWN) int netId = strncmp(email, "tel:", 4) == 0 ? NETID_MOB : NETID_MSN; if (MSN_AddUser(hContact, email, netId, LIST_FL, szMsg)) { MSN_AddUser(hContact, email, netId, LIST_PL + LIST_REMOVE); MSN_AddUser(hContact, email, netId, LIST_BL + LIST_REMOVE); MSN_AddUser(hContact, email, netId, LIST_AL); } MSN_SetContactDb(hContact, email); mir_free(szMsg); if (MSN_IsMeByContact(hContact)) displayEmailCount(hContact); return 0; } return 1; }
void CMsnProto::Lists_Populate(void) { HANDLE hContact = db_find_first(m_szModuleName); while (hContact) { HANDLE hNext = db_find_next(hContact, m_szModuleName); char szEmail[MSN_MAX_EMAIL_LEN] = ""; if (getStaticString(hContact, "wlid", szEmail, sizeof(szEmail))) getStaticString(hContact, "e-mail", szEmail, sizeof(szEmail)); if (szEmail[0]) { bool localList = getByte(hContact, "LocalList", 0) != 0; if (localList) Lists_Add(LIST_LL, NETID_MSN, szEmail, hContact); else Lists_Add(0, NETID_UNKNOWN, szEmail, hContact); } else CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); hContact = hNext; } }
BORROWED(BoxedString*) AST::getName() noexcept { static BoxedString* lambda_name = getStaticString("<lambda>"); static BoxedString* module_name = getStaticString("<module>"); switch (this->type) { case AST_TYPE::ClassDef: return ast_cast<AST_ClassDef>(this)->name.getBox(); case AST_TYPE::FunctionDef: if (ast_cast<AST_FunctionDef>(this)->name != InternedString()) return ast_cast<AST_FunctionDef>(this)->name.getBox(); return lambda_name; case AST_TYPE::Module: case AST_TYPE::Expression: case AST_TYPE::Suite: return module_name; default: RELEASE_ASSERT(0, "%d", this->type); } }
int __cdecl CMsnProto::RecvMsg(HANDLE hContact, PROTORECVEVENT* pre) { char tEmail[MSN_MAX_EMAIL_LEN]; getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_FL, tEmail)) DBDeleteContactSetting(hContact, "CList", "Hidden"); CCSDATA ccs = { hContact, PSR_MESSAGE, 0, (LPARAM)pre }; MSN_CallService(MS_PROTO_RECVMSG, 0, (LPARAM)&ccs); return 0; }
int __cdecl CMsnProto::SetStatus(int iNewStatus) { if (m_iDesiredStatus == iNewStatus) return 0; m_iDesiredStatus = iNewStatus; MSN_DebugLog("PS_SETSTATUS(%d,0)", iNewStatus); if (m_iDesiredStatus == ID_STATUS_OFFLINE) { if (msnNsThread) msnNsThread->sendTerminate(); } else if (!msnLoggedIn && m_iStatus == ID_STATUS_OFFLINE) { char szPassword[100]; int ps = getStaticString(NULL, "Password", szPassword, sizeof(szPassword)); if (ps != 0 || *szPassword == 0) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; return 0; } if (*MyOptions.szEmail == 0) { SendBroadcast(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_BADUSERID); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; return 0; } sessionList.destroy(); dcList.destroy(); usingGateway = false; int oldMode = m_iStatus; m_iStatus = ID_STATUS_CONNECTING; SendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldMode, m_iStatus); ThreadData* newThread = new ThreadData; newThread->mType = SERVER_NOTIFICATION; newThread->mIsMainThread = true; newThread->startThread(&CMsnProto::MSNServerThread, this); } else if (m_iStatus > ID_STATUS_OFFLINE) MSN_SetServerStatus(m_iDesiredStatus); return 0; }
BORROWED(BoxedList*) getSysPath() { // Unlike sys.modules, CPython handles sys.path by fetching it each time: auto path_str = getStaticString("path"); Box* _sys_path = sys_module->getattr(path_str); assert(_sys_path); if (_sys_path->cls != list_cls) { raiseExcHelper(RuntimeError, "sys.path must be a list of directory names"); } assert(_sys_path->cls == list_cls); return static_cast<BoxedList*>(_sys_path); }
void prependToSysPath(llvm::StringRef path) { BoxedList* sys_path = getSysPath(); static BoxedString* insert_str = getStaticString("insert"); CallattrFlags callattr_flags{.cls_only = false, .null_on_nonexistent = false, .argspec = ArgPassSpec(2) }; autoDecref(callattr(sys_path, insert_str, callattr_flags, autoDecref(boxInt(0)), autoDecref(boxString(path)), NULL, NULL, NULL)); } static std::string generateVersionString() { std::ostringstream oss; oss << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << '.' << PY_MICRO_VERSION; oss << '\n'; oss << "[Pyston " << PYSTON_VERSION_MAJOR << '.' << PYSTON_VERSION_MINOR << '.' << PYSTON_VERSION_MICRO << "]"; return oss.str(); }
INT_PTR CMsnProto::MsnBlockCommand(WPARAM wParam, LPARAM) { if (msnLoggedIn) { const HANDLE hContact = (HANDLE)wParam; char tEmail[MSN_MAX_EMAIL_LEN]; getStaticString(hContact, "e-mail", tEmail, sizeof(tEmail)); if (Lists_IsInList(LIST_BL, tEmail)) deleteSetting(hContact, "ApparentMode"); else setWord(hContact, "ApparentMode", ID_STATUS_OFFLINE); } return 0; }
void prependToSysPath(llvm::StringRef path) { BoxedList* sys_path = getSysPath(); static BoxedString* insert_str = getStaticString("insert"); CallattrFlags callattr_flags{.cls_only = false, .null_on_nonexistent = false, .argspec = ArgPassSpec(2) }; autoDecref(callattr(sys_path, insert_str, callattr_flags, autoDecref(boxInt(0)), autoDecref(boxString(path)), NULL, NULL, NULL)); } static BoxedClass* sys_flags_cls; class BoxedSysFlags : public Box { public: Box* division_warning, *bytes_warning, *no_user_site, *optimize; BoxedSysFlags() { auto zero = boxInt(0); assert(zero); division_warning = incref(zero); bytes_warning = incref(zero); no_user_site = incref(zero); optimize = incref(zero); Py_DECREF(zero); } DEFAULT_CLASS(sys_flags_cls); static Box* __new__(Box* cls, Box* args, Box* kwargs) { raiseExcHelper(TypeError, "cannot create 'sys.flags' instances"); } static void dealloc(BoxedSysFlags* self) { Py_DECREF(self->division_warning); Py_DECREF(self->bytes_warning); Py_DECREF(self->no_user_site); Py_DECREF(self->optimize); } }; static std::string generateVersionString() { std::ostringstream oss; oss << PY_MAJOR_VERSION << '.' << PY_MINOR_VERSION << '.' << PY_MICRO_VERSION; oss << '\n'; oss << "[Pyston " << PYSTON_VERSION_MAJOR << '.' << PYSTON_VERSION_MINOR << '.' << PYSTON_VERSION_MICRO << "]"; return oss.str(); }
INT_PTR CMsnProto::MsnViewProfile(WPARAM wParam, LPARAM) { const HANDLE hContact = (HANDLE)wParam; char buf[64], *cid; if (hContact == NULL) cid = mycid; else { cid = buf; if (getStaticString(hContact, "CID", buf, 30)) return 0; } char tUrl[256]; mir_snprintf(tUrl, sizeof(tUrl), "http://cid-%I64X.profiles.live.com", _atoi64(cid)); MsnInvokeMyURL(false, tUrl); return 0; }
void setupSys() { sys_modules_dict = new BoxedDict(); constants.push_back(sys_modules_dict); // This is ok to call here because we've already created the sys_modules_dict sys_module = createModule(autoDecref(boxString("sys"))); // sys_module is what holds on to all of the other modules: Py_INCREF(sys_module); late_constants.push_back(sys_module); sys_module->giveAttrBorrowed("modules", sys_modules_dict); BoxedList* sys_path = new BoxedList(); constants.push_back(sys_path); sys_module->giveAttrBorrowed("path", sys_path); sys_module->giveAttr("argv", new BoxedList()); sys_module->giveAttr("exc_info", new BoxedBuiltinFunctionOrMethod(FunctionMetadata::create((void*)sysExcInfo, BOXED_TUPLE, 0), "exc_info", exc_info_doc)); sys_module->giveAttr("exc_clear", new BoxedBuiltinFunctionOrMethod(FunctionMetadata::create((void*)sysExcClear, NONE, 0), "exc_clear", exc_clear_doc)); sys_module->giveAttr( "exit", new BoxedBuiltinFunctionOrMethod(FunctionMetadata::create((void*)sysExit, NONE, 1, false, false), "exit", { None }, NULL, exit_doc)); sys_module->giveAttr("warnoptions", new BoxedList()); sys_module->giveAttrBorrowed("py3kwarning", Py_False); sys_module->giveAttr("byteorder", boxString(isLittleEndian() ? "little" : "big")); sys_module->giveAttr("platform", boxString(Py_GetPlatform())); sys_module->giveAttr("executable", boxString(Py_GetProgramFullPath())); sys_module->giveAttr( "_getframe", new BoxedFunction(FunctionMetadata::create((void*)sysGetFrame, UNKNOWN, 1, false, false), { NULL })); sys_module->giveAttr("_current_frames", new BoxedFunction(FunctionMetadata::create((void*)sysCurrentFrames, UNKNOWN, 0))); sys_module->giveAttr("getdefaultencoding", new BoxedBuiltinFunctionOrMethod( FunctionMetadata::create((void*)sysGetDefaultEncoding, STR, 0), "getdefaultencoding", getdefaultencoding_doc)); sys_module->giveAttr("getfilesystemencoding", new BoxedBuiltinFunctionOrMethod( FunctionMetadata::create((void*)sysGetFilesystemEncoding, STR, 0), "getfilesystemencoding", getfilesystemencoding_doc)); sys_module->giveAttr("getrecursionlimit", new BoxedBuiltinFunctionOrMethod( FunctionMetadata::create((void*)sysGetRecursionLimit, UNKNOWN, 0), "getrecursionlimit", getrecursionlimit_doc)); // As we don't support compile() etc yet force 'dont_write_bytecode' to true. sys_module->giveAttrBorrowed("dont_write_bytecode", Py_True); sys_module->giveAttr("prefix", boxString(Py_GetPrefix())); sys_module->giveAttr("exec_prefix", boxString(Py_GetExecPrefix())); sys_module->giveAttr("copyright", boxString("Copyright 2014-2016 Dropbox.\nAll Rights Reserved.\n\nCopyright (c) 2001-2014 " "Python Software Foundation.\nAll Rights Reserved.\n\nCopyright (c) 2000 " "BeOpen.com.\nAll Rights Reserved.\n\nCopyright (c) 1995-2001 Corporation for " "National Research Initiatives.\nAll Rights Reserved.\n\nCopyright (c) " "1991-1995 Stichting Mathematisch Centrum, Amsterdam.\nAll Rights Reserved.")); sys_module->giveAttr("version", boxString(generateVersionString())); sys_module->giveAttr("hexversion", boxInt(PY_VERSION_HEX)); sys_module->giveAttr("subversion", BoxedTuple::create({ autoDecref(boxString("Pyston")), autoDecref(boxString("")), autoDecref(boxString("")) })); sys_module->giveAttr("maxint", boxInt(PYSTON_INT_MAX)); sys_module->giveAttr("maxsize", boxInt(PY_SSIZE_T_MAX)); sys_flags_cls = BoxedClass::create(type_cls, object_cls, 0, 0, sizeof(BoxedSysFlags), false, "flags", false, NULL, NULL, false); sys_flags_cls->giveAttr( "__new__", new BoxedFunction(FunctionMetadata::create((void*)BoxedSysFlags::__new__, UNKNOWN, 1, true, true))); sys_flags_cls->tp_dealloc = (destructor)BoxedSysFlags::dealloc; #define ADD(name) sys_flags_cls->giveAttrMember(STRINGIFY(name), T_OBJECT, offsetof(BoxedSysFlags, name)); ADD(division_warning); ADD(bytes_warning); ADD(no_user_site); ADD(optimize); #undef ADD #define SET_SYS_FROM_STRING(key, value) sys_module->giveAttr((key), (value)) #ifdef Py_USING_UNICODE SET_SYS_FROM_STRING("maxunicode", PyInt_FromLong(PyUnicode_GetMax())); #endif /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */ #ifndef PY_NO_SHORT_FLOAT_REPR SET_SYS_FROM_STRING("float_repr_style", PyString_FromString("short")); #else SET_SYS_FROM_STRING("float_repr_style", PyString_FromString("legacy")); #endif sys_flags_cls->freeze(); auto sys_str = getStaticString("sys"); for (auto& md : sys_methods) { sys_module->giveAttr(md.ml_name, new BoxedCApiFunction(&md, NULL, sys_str)); } sys_module->giveAttrBorrowed("__displayhook__", sys_module->getattr(autoDecref(internStringMortal("displayhook")))); sys_module->giveAttr("flags", new BoxedSysFlags()); }
void setupSys() { sys_modules_dict = new BoxedDict(); PyThreadState_GET()->interp->modules = incref(sys_modules_dict); constants.push_back(sys_modules_dict); // This is ok to call here because we've already created the sys_modules_dict sys_module = createModule(autoDecref(boxString("sys"))); // sys_module is what holds on to all of the other modules: Py_INCREF(sys_module); late_constants.push_back(sys_module); sys_module->giveAttrBorrowed("modules", sys_modules_dict); BoxedList* sys_path = new BoxedList(); constants.push_back(sys_path); sys_module->giveAttrBorrowed("path", sys_path); sys_module->giveAttr("argv", new BoxedList()); sys_module->giveAttr("exc_info", new BoxedBuiltinFunctionOrMethod(BoxedCode::create((void*)sysExcInfo, BOXED_TUPLE, 0, "exc_info", exc_info_doc))); sys_module->giveAttr("exc_clear", new BoxedBuiltinFunctionOrMethod( BoxedCode::create((void*)sysExcClear, NONE, 0, "exc_clear", exc_clear_doc))); sys_module->giveAttr( "exit", new BoxedBuiltinFunctionOrMethod( BoxedCode::create((void*)sysExit, NONE, 1, false, false, "exit", exit_doc), { Py_None }, NULL)); sys_module->giveAttr("warnoptions", new BoxedList()); sys_module->giveAttrBorrowed("py3kwarning", Py_False); sys_module->giveAttr("byteorder", boxString(isLittleEndian() ? "little" : "big")); sys_module->giveAttr("platform", boxString(Py_GetPlatform())); sys_module->giveAttr("executable", boxString(Py_GetProgramFullPath())); sys_module->giveAttr( "_getframe", new BoxedFunction(BoxedCode::create((void*)sysGetFrame, UNKNOWN, 1, false, false, "_getframe"), { NULL })); sys_module->giveAttr("_current_frames", new BoxedFunction(BoxedCode::create((void*)sysCurrentFrames, UNKNOWN, 0, "_current_frames"))); sys_module->giveAttr("getdefaultencoding", new BoxedBuiltinFunctionOrMethod(BoxedCode::create( (void*)sysGetDefaultEncoding, STR, 0, "getdefaultencoding", getdefaultencoding_doc))); sys_module->giveAttr("getfilesystemencoding", new BoxedBuiltinFunctionOrMethod(BoxedCode::create( (void*)sysGetFilesystemEncoding, STR, 0, "getfilesystemencoding", getfilesystemencoding_doc))); sys_module->giveAttr("getrecursionlimit", new BoxedBuiltinFunctionOrMethod(BoxedCode::create( (void*)sysGetRecursionLimit, UNKNOWN, 0, "getrecursionlimit", getrecursionlimit_doc))); sys_module->giveAttr("dont_write_bytecode", boxBool(Py_DontWriteBytecodeFlag)); sys_module->giveAttr("prefix", boxString(Py_GetPrefix())); sys_module->giveAttr("exec_prefix", boxString(Py_GetExecPrefix())); sys_module->giveAttr("copyright", boxString("Copyright 2014-2016 Dropbox.\nAll Rights Reserved.\n\nCopyright (c) 2001-2014 " "Python Software Foundation.\nAll Rights Reserved.\n\nCopyright (c) 2000 " "BeOpen.com.\nAll Rights Reserved.\n\nCopyright (c) 1995-2001 Corporation for " "National Research Initiatives.\nAll Rights Reserved.\n\nCopyright (c) " "1991-1995 Stichting Mathematisch Centrum, Amsterdam.\nAll Rights Reserved.")); sys_module->giveAttr("version", boxString(generateVersionString())); sys_module->giveAttr("hexversion", boxInt(PY_VERSION_HEX)); sys_module->giveAttr("subversion", BoxedTuple::create({ autoDecref(boxString("Pyston")), autoDecref(boxString("")), autoDecref(boxString("")) })); sys_module->giveAttr("maxint", boxInt(PYSTON_INT_MAX)); sys_module->giveAttr("maxsize", boxInt(PY_SSIZE_T_MAX)); #define SET_SYS_FROM_STRING(key, value) sys_module->giveAttr((key), (value)) #ifdef Py_USING_UNICODE SET_SYS_FROM_STRING("maxunicode", PyInt_FromLong(PyUnicode_GetMax())); #endif /* float repr style: 0.03 (short) vs 0.029999999999999999 (legacy) */ #ifndef PY_NO_SHORT_FLOAT_REPR SET_SYS_FROM_STRING("float_repr_style", PyString_FromString("short")); #else SET_SYS_FROM_STRING("float_repr_style", PyString_FromString("legacy")); #endif auto sys_str = getStaticString("sys"); for (auto& md : sys_methods) { sys_module->giveAttr(md.ml_name, new BoxedCApiFunction(&md, NULL, sys_str)); } sys_module->giveAttrBorrowed("__displayhook__", sys_module->getattr(autoDecref(internStringMortal("displayhook")))); }
CMsnProto::CMsnProto(const char* aProtoName, const TCHAR* aUserName) : contList(10, CompareLists), grpList(10, CompareId), sttThreads(10, PtrKeySortT), sessionList(10, PtrKeySortT), dcList(10, PtrKeySortT), msgQueueList(1), msgCache(5, CompareId) { char path[MAX_PATH]; m_iVersion = 2; m_tszUserName = mir_tstrdup(aUserName); m_szModuleName = mir_strdup(aProtoName); m_szProtoName = mir_strdup(aProtoName); _strlwr(m_szProtoName); m_szProtoName[0] = (char)toupper(m_szProtoName[0]); mir_snprintf(path, sizeof(path), "%s/Status", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/IdleTS", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/p2pMsgId", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/MobileEnabled", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); mir_snprintf(path, sizeof(path), "%s/MobileAllowed", m_szModuleName); MSN_CallService(MS_DB_SETSETTINGRESIDENT, TRUE, (LPARAM)path); // Protocol services and events... hMSNNudge = CreateProtoEvent("/Nudge"); CreateProtoService(PS_CREATEACCMGRUI, &CMsnProto::SvcCreateAccMgrUI); CreateProtoService(PS_GETAVATARINFOT, &CMsnProto::GetAvatarInfo); CreateProtoService(PS_GETMYAWAYMSG, &CMsnProto::GetMyAwayMsg); CreateProtoService(PS_LEAVECHAT, &CMsnProto::OnLeaveChat); CreateProtoService(PS_GETMYAVATART, &CMsnProto::GetAvatar); CreateProtoService(PS_SETMYAVATART, &CMsnProto::SetAvatar); CreateProtoService(PS_GETAVATARCAPS, &CMsnProto::GetAvatarCaps); CreateProtoService(PS_GET_LISTENINGTO, &CMsnProto::GetCurrentMedia); CreateProtoService(PS_SET_LISTENINGTO, &CMsnProto::SetCurrentMedia); CreateProtoService(PS_SETMYNICKNAME, &CMsnProto::SetNickName); CreateProtoService(MSN_SEND_NUDGE, &CMsnProto::SendNudge); CreateProtoService(MSN_GETUNREAD_EMAILCOUNT, &CMsnProto::GetUnreadEmailCount); // service to get from protocol chat buddy info // CreateProtoService(MS_GC_PROTO_GETTOOLTIPTEXT, &CMsnProto::GCGetToolTipText); HookProtoEvent(ME_MSG_WINDOWPOPUP, &CMsnProto::OnWindowPopup); // HookProtoEvent(ME_MSG_WINDOWEVENT, &CMsnProto::OnWindowEvent); HookProtoEvent(ME_CLIST_GROUPCHANGE, &CMsnProto::OnGroupChange); HookProtoEvent(ME_OPT_INITIALISE, &CMsnProto::OnOptionsInit); HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CMsnProto::OnContactDoubleClicked); LoadOptions(); HANDLE hContact = (HANDLE)MSN_CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); while (hContact != NULL) { if (MSN_IsMyContact(hContact)) { deleteSetting(hContact, "Status"); deleteSetting(hContact, "IdleTS"); deleteSetting(hContact, "p2pMsgId"); deleteSetting(hContact, "AccList"); // DBDeleteContactSetting(hContact, "CList", "StatusMsg"); } hContact = (HANDLE)MSN_CallService(MS_DB_CONTACT_FINDNEXT,(WPARAM)hContact, 0); } deleteSetting(NULL, "MobileEnabled"); deleteSetting(NULL, "MobileAllowed"); if (getStaticString(NULL, "LoginServer", path, sizeof(path)) == 0 && (strcmp(path, MSN_DEFAULT_LOGIN_SERVER) == 0 || strcmp(path, MSN_DEFAULT_GATEWAY) == 0)) deleteSetting(NULL, "LoginServer"); if (MyOptions.SlowSend) { if (DBGetContactSettingDword(NULL, "SRMsg", "MessageTimeout", 10000) < 60000) DBWriteContactSettingDword(NULL, "SRMsg", "MessageTimeout", 60000); if (DBGetContactSettingDword(NULL, "SRMM", "MessageTimeout", 10000) < 60000) DBWriteContactSettingDword(NULL, "SRMM", "MessageTimeout", 60000); } mailsoundname = (char*)mir_alloc(64); mir_snprintf(mailsoundname, 64, "%s:Hotmail", m_szModuleName); SkinAddNewSoundExT(mailsoundname, m_tszUserName, LPGENT("Live Mail")); alertsoundname = (char*)mir_alloc(64); mir_snprintf(alertsoundname, 64, "%s:Alerts", m_szModuleName); SkinAddNewSoundExT(alertsoundname, m_tszUserName, LPGENT("Live Alert")); m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE; MSN_InitThreads(); Lists_Init(); MsgQueue_Init(); P2pSessions_Init(); InitCustomFolders(); TCHAR szBuffer[MAX_PATH]; char szDbsettings[64]; NETLIBUSER nlu1 = {0}; nlu1.cbSize = sizeof(nlu1); nlu1.flags = NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu1.szSettingsModule = szDbsettings; nlu1.ptszDescriptiveName = szBuffer; mir_snprintf(szDbsettings, sizeof(szDbsettings), "%s_HTTPS", m_szModuleName); mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s plugin HTTPS connections"), m_tszUserName); hNetlibUserHttps = (HANDLE)MSN_CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu1); NETLIBUSER nlu = {0}; nlu.cbSize = sizeof(nlu); nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR; nlu.szSettingsModule = m_szModuleName; nlu.ptszDescriptiveName = szBuffer; nlu.szHttpGatewayUserAgent = (char*)MSN_USER_AGENT; nlu.pfnHttpGatewayInit = msn_httpGatewayInit; nlu.pfnHttpGatewayWrapSend = msn_httpGatewayWrapSend; nlu.pfnHttpGatewayUnwrapRecv = msn_httpGatewayUnwrapRecv; mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("%s plugin connections"), m_tszUserName); hNetlibUser = (HANDLE)MSN_CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu); }
void CMsnProto::MSNConnDetectThread( void* ) { char parBuf[512] = ""; memset(&MyConnection, 0, sizeof(MyConnection)); MyConnection.icf = IsIcfEnabled(); bool portsMapped = getByte("NLSpecifyIncomingPorts", 0) != 0; unsigned gethst = getByte("AutoGetHost", 1); switch (gethst) { case 0: MSN_DebugLog("P2PNAT User overwrote IP connection is guessed by user settings only"); // User specified host by himself so check if it matches MSN information // if it does, move to connection type autodetection, // if it does not, guess connection type from available info getStaticString(NULL, "YourHost", parBuf, sizeof(parBuf)); if (msnExternalIP == NULL || strcmp(msnExternalIP, parBuf) != 0) { MyConnection.extIP = inet_addr(parBuf); if (MyConnection.extIP == INADDR_NONE) { PHOSTENT myhost = gethostbyname(parBuf); if (myhost != NULL) MyConnection.extIP = ((PIN_ADDR)myhost->h_addr)->S_un.S_addr; else setByte("AutoGetHost", 1); } if (MyConnection.extIP != INADDR_NONE) { MyConnection.intIP = MyConnection.extIP; MyConnection.udpConType = MyConnection.extIP ? (ConEnum)portsMapped : conUnknown; MyConnection.CalculateWeight(); return; } else MyConnection.extIP = 0; } break; case 1: if (msnExternalIP != NULL) MyConnection.extIP = inet_addr(msnExternalIP); else { gethostname(parBuf, sizeof(parBuf)); PHOSTENT myhost = gethostbyname(parBuf); if (myhost != NULL) MyConnection.extIP = ((PIN_ADDR)myhost->h_addr)->S_un.S_addr; } MyConnection.intIP = MyConnection.extIP; break; case 2: MyConnection.udpConType = conUnknown; MyConnection.CalculateWeight(); return; } if (getByte( "NLSpecifyOutgoingPorts", 0)) { // User specified outgoing ports so the connection must be firewalled // do not autodetect and guess connection type from available info MyConnection.intIP = MyConnection.extIP; MyConnection.udpConType = (ConEnum)portsMapped; MyConnection.upnpNAT = false; MyConnection.CalculateWeight(); return; } MSNatDetect(); // If user mapped incoming ports consider direct connection if (portsMapped) { MSN_DebugLog("P2PNAT User manually mapped ports for incoming connection"); switch(MyConnection.udpConType) { case conUnknown: case conFirewall: case conISALike: MyConnection.udpConType = conDirect; break; case conUnknownNAT: case conPortRestrictNAT: case conIPRestrictNAT: case conSymmetricNAT: MyConnection.upnpNAT = true; break; } } MSN_DebugLog("P2PNAT Connection %s found UPnP: %d ICF: %d", conStr[MyConnection.udpConType], MyConnection.upnpNAT, MyConnection.icf); MyConnection.CalculateWeight(); }