NS_IMETHODIMP nsIMAPHostSessionList::SetOnlineDirForHost(const char *serverKey, const char *onlineDir) { PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { if (onlineDir) host->fOnlineDir = onlineDir; } PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
NS_IMETHODIMP nsIMAPHostSessionList::SetPasswordForHost(const char *serverKey, const char *password) { PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { PR_FREEIF(host->fCachedPassword); if (password) host->fCachedPassword = NS_strdup(password); } PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
NS_IMETHODIMP nsIMAPHostSessionList::SetNamespaceHierarchyDelimiterFromMailboxForHost(const char *serverKey, const char *boxName, char delimiter) { PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { nsIMAPNamespace *ns = host->fNamespaceList->GetNamespaceForMailbox(boxName); if (ns && !ns->GetIsDelimiterFilledIn()) ns->SetDelimiter(delimiter, true); } PR_ExitMonitor(gCachedHostInfoMonitor); return (host) ? NS_OK : NS_ERROR_ILLEGAL_VALUE ; }
NS_IMETHODIMP nsIMAPHostSessionList::GetNumberOfNamespacesForHost(const char *serverKey, uint32_t &result) { int32_t intResult = 0; PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) intResult = host->fNamespaceList->GetNumberOfNamespaces(); PR_ExitMonitor(gCachedHostInfoMonitor); NS_ASSERTION(intResult >= 0, "negative number of namespaces"); result = (uint32_t) intResult; return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
NS_IMETHODIMP nsIMAPHostSessionList::FindShellInCacheForHost(const char *serverKey, const char *mailboxName, const char *UID, IMAP_ContentModifiedType modType, nsIMAPBodyShell **shell) { nsCString uidString(UID); PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host && host->fShellCache) NS_IF_ADDREF(*shell = host->fShellCache->FindShellForUID(uidString, mailboxName, modType)); PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
// Returns NULL if there is no personal namespace on the given host NS_IMETHODIMP nsIMAPHostSessionList::GetOnlineInboxPathForHost(const char *serverKey, nsString &result) { PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { nsIMAPNamespace *ns = NULL; ns = host->fNamespaceList->GetDefaultNamespaceOfType(kPersonalNamespace); if (ns) { CopyASCIItoUTF16(nsDependentCString(ns->GetPrefix()), result); result.AppendLiteral("INBOX"); } } else result.Truncate(); PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
NS_IMETHODIMP nsIMAPHostSessionList::AddHostToList(const char *serverKey, nsIImapIncomingServer *server) { nsIMAPHostInfo *newHost=NULL; PR_EnterMonitor(gCachedHostInfoMonitor); if (!FindHost(serverKey)) { // stick it on the front newHost = new nsIMAPHostInfo(serverKey, server); if (newHost) { newHost->fNextHost = fHostInfoList; fHostInfoList = newHost; } } PR_ExitMonitor(gCachedHostInfoMonitor); return (newHost == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
NS_IMETHODIMP nsIMAPHostSessionList::AddShellToCacheForHost(const char *serverKey, nsIMAPBodyShell *shell) { nsresult rv = NS_OK; PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { if (host->fShellCache) { if (!host->fShellCache->AddShellToCache(shell)) rv = NS_ERROR_UNEXPECTED; } } else rv = NS_ERROR_ILLEGAL_VALUE; PR_ExitMonitor(gCachedHostInfoMonitor); return rv; }
NS_IMETHODIMP nsIMAPHostSessionList::AddShellToCacheForHost(const char *serverKey, nsIMAPBodyShell *shell) { PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { if (host->fShellCache) { bool rv = host->fShellCache->AddShellToCache(shell); PR_ExitMonitor(gCachedHostInfoMonitor); return rv; } else { PR_ExitMonitor(gCachedHostInfoMonitor); return false; } } PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
// Returns NULL if there is no personal namespace on the given host NS_IMETHODIMP nsIMAPHostSessionList::GetOnlineInboxPathForHost(const char *serverKey, nsString &result) { PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey); if (host) { nsIMAPNamespace *ns = NULL; ns = host->fNamespaceList->GetDefaultNamespaceOfType(kPersonalNamespace); if (ns) { result.AssignWithConversion(ns->GetPrefix()); result.AppendLiteral("INBOX"); } } else { result.SetLength(0); } PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }
void UpdateUserModes(struct Luser *user, char *modes) { int PLUS = 1; int umode; unsigned int ii; if (!modes || !user) return; for (ii = 0; ii < strlen(modes); ii++) { if (modes[ii] == '+') { PLUS = 1; continue; } if (modes[ii] == '-') { PLUS = 0; continue; } umode = 0; if (modes[ii] == 'i') umode = UMODE_I; if (modes[ii] == 's') umode = UMODE_S; if (modes[ii] == 'w') umode = UMODE_W; if (modes[ii] == 'o') umode = UMODE_O; #ifdef DANCER if (modes[ii] == 'e') if (PLUS) { struct NickInfo* realptr = FindNick(user->nick); if (realptr) { realptr->flags |= NS_IDENTIFIED; RecordCommand("User %s has +e umode, marking as identified",user->nick); umode = UMODE_E; } else { /* Blech, who is screwing with us? */ toserv(":%s MODE %s -e\r\n", Me.name, user->nick); RecordCommand("User %s has +e umode but is not known to me, setting -e", user->nick); umode = 0; } } #endif /* DANCER */ if (!umode) continue; if (PLUS) { if ((umode == UMODE_O) && (!IsOperator(user))) { #ifdef STATSERVICES char *hostname, *domain; struct HostHash *hosth, *domainh; time_t currtime = current_ts; #endif #ifdef NICKSERVICES CheckOper(user); #endif Network->TotalOperators++; if (SafeConnect) SendUmode(OPERUMODE_O, "*** New Operator: %s (%s@%s) [%s]", user->nick, user->username, user->hostname, user->server ? user->server->name : "*unknown*"); #ifdef STATSERVICES if (Network->TotalOperators > Network->MaxOperators) { Network->MaxOperators = Network->TotalOperators; Network->MaxOperators_ts = current_ts; if ((Network->MaxOperators % 5) == 0) { /* inform +y people of new max oper count */ SendUmode(OPERUMODE_Y, "*** New Max Operator Count: %ld", Network->MaxOperators); putlog(LOG2, "New Max Operator Count: %ld", Network->MaxOperators); } } if (Network->TotalOperators > Network->MaxOperatorsT) { Network->MaxOperatorsT = Network->TotalOperators; Network->MaxOperatorsT_ts = current_ts; } #endif if (user->server) { user->server->numopers++; #ifdef STATSERVICES if (user->server->numopers > user->server->maxopers) { user->server->maxopers = user->server->numopers; user->server->maxopers_ts = current_ts; } #endif } #ifdef STATSERVICES hostname = user->hostname; if ((hosth = FindHost(hostname))) { hosth->curropers++; if (hosth->curropers > hosth->maxopers) { hosth->maxopers = hosth->curropers; hosth->maxopers_ts = currtime; } } if ((domain = GetDomain(hostname))) { if ((domainh = FindDomain(domain))) { domainh->curropers++; if (domainh->curropers > domainh->maxopers) { domainh->maxopers = domainh->curropers; domainh->maxopers_ts = currtime; } } } #endif /* STATSERVICES */ } user->umodes |= umode; } else { if ((umode == UMODE_O) && (IsOperator(user))) { #ifdef STATSERVICES char *hostname, *domain; struct HostHash *hosth, *domainh; #endif Network->TotalOperators--; if (user->server) user->server->numopers--; #ifdef STATSERVICES hostname = user->hostname; if ((hosth = FindHost(hostname))) hosth->curropers--; if ((domain = GetDomain(hostname))) if ((domainh = FindDomain(domain))) domainh->curropers--; #endif } user->umodes &= ~umode; } } } /* UpdateUserModes() */
static void ss_host(struct Luser *lptr, int ac, char **av) { struct HostHash *hosth; char str[MAXLINE + 1]; if (ac < 2) { notice(n_StatServ, lptr->nick, "Syntax: HOST <hostname>"); notice(n_StatServ, lptr->nick, ERR_MORE_INFO, n_StatServ, "HOST"); return; } RecordCommand("%s: %s!%s@%s HOST [%s]", n_StatServ, lptr->nick, lptr->username, lptr->hostname, av[1]); if (!(hosth = FindHost(av[1]))) { notice(n_StatServ, lptr->nick, "No hostnames matching [\002%s\002] found", av[1]); return; } notice(n_StatServ, lptr->nick, "Statistics for hostname: \002%s\002", av[1]); notice(n_StatServ, lptr->nick, "Current Clients: %ld (%ld unique)", hosth->currclients, hosth->currunique); notice(n_StatServ, lptr->nick, "Current Opers: %ld", hosth->curropers); strlcpy(str, ctime(&hosth->maxclients_ts), sizeof(str)); str[strlen(str) - 1] = '\0'; notice(n_StatServ, lptr->nick, "Max Clients: %ld on %s", hosth->maxclients, str); strlcpy(str, ctime(&hosth->maxunique_ts), sizeof(str)); str[strlen(str) - 1] = '\0'; notice(n_StatServ, lptr->nick, "Max Unique: %ld on %s", hosth->maxunique, str); if (hosth->maxopers_ts) { strlcpy(str, "on ", sizeof(str)); strlcat(str, ctime(&hosth->maxopers_ts), sizeof(str)); str[strlen(str) - 1] = '\0'; } else str[0] = '\0'; notice(n_StatServ, lptr->nick, "Max Operators: %ld %s", hosth->maxopers, str); notice(n_StatServ, lptr->nick, "Identd Users: %ld", hosth->curridentd); notice(n_StatServ, lptr->nick, "Non-Identd Users: %ld", hosth->currclients - hosth->curridentd); } /* ss_host() */
// do we need this? What should we do about the master thing? // Make sure this is running in the Mozilla thread when called NS_IMETHODIMP nsIMAPHostSessionList::CommitNamespacesForHost(nsIImapIncomingServer *aHost) { NS_ENSURE_ARG_POINTER(aHost); nsCString serverKey; nsCOMPtr <nsIMsgIncomingServer> incomingServer = do_QueryInterface(aHost); if (!incomingServer) return NS_ERROR_NULL_POINTER; nsresult rv = incomingServer->GetKey(serverKey); NS_ENSURE_SUCCESS(rv, rv); PR_EnterMonitor(gCachedHostInfoMonitor); nsIMAPHostInfo *host = FindHost(serverKey.get()); if (host) { host->fGotNamespaces = true; // so we only issue NAMESPACE once per host per session. EIMAPNamespaceType type = kPersonalNamespace; for (int i = 1; i <= 3; i++) { switch(i) { case 1: type = kPersonalNamespace; break; case 2: type = kPublicNamespace; break; case 3: type = kOtherUsersNamespace; break; default: type = kPersonalNamespace; break; } int32 numInNS = host->fNamespaceList->GetNumberOfNamespaces(type); if (numInNS == 0) SetNamespacesPrefForHost(aHost, type, ""); else if (numInNS >= 1) { char *pref = PR_smprintf(""); for (int count = 1; count <= numInNS; count++) { nsIMAPNamespace *ns = host->fNamespaceList->GetNamespaceNumber(count, type); if (ns) { if (count > 1) { // append the comma char *tempPref = PR_smprintf("%s,",pref); PR_FREEIF(pref); pref = tempPref; } char *tempPref = PR_smprintf("%s\"%s\"",pref,ns->GetPrefix()); PR_FREEIF(pref); pref = tempPref; } } if (pref) { SetNamespacesPrefForHost(aHost, type, pref); PR_Free(pref); } } } // clear, but don't delete the entries in, the temp namespace list host->fTempNamespaceList->ClearNamespaces(true, true, false); // Now reset all of libmsg's namespace references. // Did I mention this needs to be running in the mozilla thread? aHost->ResetNamespaceReferences(); } PR_ExitMonitor(gCachedHostInfoMonitor); return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK; }