int main(int argc, char **argv) { char **av = argv; struct sockaddr_in host; afs_int32 code; struct hostent *hp; char hnamebuf[200]; struct timeval tv; int noAuth = 1; /* Default is authenticated connections */ argc--, av++; if (argc < 1) { printf("usage: pxclient <serverHost>\n"); exit(1); } memset(&host, 0, sizeof(struct sockaddr_in)); host.sin_family = AF_INET; host.sin_addr.s_addr = inet_addr(av[0]); #ifdef STRUCT_SOCKADDR_HAS_SA_LEN host.sin_len = sizeof(struct sockaddr_in); #endif if (host.sin_addr.s_addr != -1) { strcpy(hnamebuf, av[0]); } else { hp = gethostbyname(av[0]); if (hp) { host.sin_family = hp->h_addrtype; memcpy((caddr_t) & host.sin_addr, hp->h_addr, hp->h_length); } else { printf("unknown server host %s\n", av[0]); exit(1); } } if ((code = pxclient_Initialize(noAuth, host.sin_addr.s_addr)) != 0) { printf("Couldn't initialize fs library (code=%d).\n", code); exit(1); } code = ubik_Call(RXAFS_GetTime, cstruct, 0, &tv.tv_sec, &tv.tv_usec); if (!code) printf("AFS_GetTime on %s sec=%ld, usec=%ld\n", av[0], tv.tv_sec, (long int)tv.tv_usec); else printf("return code is %d\n", code); #ifdef notdef while (1) { char line[500]; int nargs; printf("fs> "); if (fgets(line, 499, stdin) != NULL) { char *oper; char **argp = args; GetArgs(line, argp, &nargs); oper = &argp[0][0]; ++argp, --nargs; if (!strcmp(oper, "probe")) { code = ubik_Call(RXAFS_GetTime, cstruct, 0, &tv.tv_sec, &tv.tv_usec); printf("return code is %d\n", code); if (!code) printf("sec=%d\n", tv.tv_sec); } else if (!strcmp(oper, "fsstats")) { struct afsStatistics stats; code = ubik_AFS_GetStatistics(cstruct, 0, &stats); printf("return code is %d\n", code); } else if (!strcmp(oper, "fd")) { code = FetchData(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "fs")) { code = FetchStatus(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "fa")) { code = FetchACL(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "sd")) { code = StoreData(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "ss")) { code = StoreStatus(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "sa")) { code = StoreACL(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "cf")) { code = CreateFile(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "rf")) { code = RemoveFile(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "rn")) { code = Rename(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "sl")) { code = Symlink(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "hl")) { code = HardLink(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "md")) { code = MakeDir(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "rd")) { code = RemoveDir(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "rdd")) { code = Readdir(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "mm")) { code = MakeMountPoint(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "rt")) { code = ReleaseTokens(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "bs")) { code = BulkStatus(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "lk")) { code = Lookup(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "gt")) { code = GetToken(argp); printf("return code is %d\n", code); } else if (!strcmp(oper, "ka")) { code = KeepAlive(argp); printf("return code is %d\n", code); } else if ((!strcmp(oper, "q")) || !strcmp(oper, "quit")) exit(0); else { printf("Unknown oper! Available operations: \n\n"); printf("fd <vnode> <unique> <pos> <len>\n"); printf("fs <vnode> <unique>\n"); printf("fa <vnode> <unique>\n"); printf ("sd <vnode> <unique> <pos> <len> <flen> [<mode>|-1] [<owner>|-1] [<length>|-1] <string>\n"); printf ("ss <vnode> <unique> [<mode>|-1] [<owner>|-1] [<length>|-1]\n"); printf("sa <vnode> <unique> <string>\n"); printf("rf <vnode> <unique> <name>\n"); printf ("cf <vnode> <unique> <name> [<mode>|-1] [<owner>|-1] [<length>|-1]\n"); printf ("rn <ovnode> <ounique> <oname> <nvnode> <nunique> <nname>\n"); printf ("sl <vnode> <unique> <name> <contents> [<mode>|-1] [<owner>|-1] [<length>|-1]\n"); printf("hl <dvnode> <dunique> <name> <evnode> <eunique>\n"); printf ("md <vnode> <unique> <name> [<mode>|-1] [<owner>|-1] [<length>|-1]\n"); printf("rd <vnode> <unique> <name>\n"); printf("rdd <vnode> <unique> <pos> <len>\n"); printf("lk <vnode> <unique> <name>\n"); printf("gt <vnode> <unique> <tokenID>\n"); printf("ka <vol.l> <vnode> <unique> <isExec> <kaTime>\n"); } } } #endif return 0; }
NS_IMETHODIMP nsMsgGroupView::CellTextForColumn(int32_t aRow, const char16_t *aColumnName, nsAString &aValue) { if (!IsValidIndex(aRow)) return NS_MSG_INVALID_DBVIEW_INDEX; if (m_flags[aRow] & MSG_VIEW_FLAG_DUMMY && aColumnName[0] != 'u') { nsCOMPtr <nsIMsgDBHdr> msgHdr; nsresult rv = GetMsgHdrForViewIndex(aRow, getter_AddRefs(msgHdr)); NS_ENSURE_SUCCESS(rv, rv); nsString hashKey; rv = HashHdr(msgHdr, hashKey); if (NS_FAILED(rv)) return NS_OK; nsCOMPtr<nsIMsgThread> msgThread; m_groupsTable.Get(hashKey, getter_AddRefs(msgThread)); nsMsgGroupThread * groupThread = static_cast<nsMsgGroupThread *>(msgThread.get()); if (aColumnName[0] == 's' && aColumnName[1] == 'u' ) { uint32_t flags; bool rcvDate = false; msgHdr->GetFlags(&flags); aValue.Truncate(); nsString tmp_str; switch (m_sortType) { case nsMsgViewSortType::byReceived: rcvDate = true; case nsMsgViewSortType::byDate: { uint32_t ageBucket = 0; GetAgeBucketValue(msgHdr, &ageBucket, rcvDate); switch (ageBucket) { case 1: if (m_kTodayString.IsEmpty()) m_kTodayString.Adopt(GetString(MOZ_UTF16("today"))); aValue.Assign(m_kTodayString); break; case 2: if (m_kYesterdayString.IsEmpty()) m_kYesterdayString.Adopt(GetString(MOZ_UTF16("yesterday"))); aValue.Assign(m_kYesterdayString); break; case 3: if (m_kLastWeekString.IsEmpty()) m_kLastWeekString.Adopt(GetString(MOZ_UTF16("lastWeek"))); aValue.Assign(m_kLastWeekString); break; case 4: if (m_kTwoWeeksAgoString.IsEmpty()) m_kTwoWeeksAgoString.Adopt(GetString(MOZ_UTF16("twoWeeksAgo"))); aValue.Assign(m_kTwoWeeksAgoString); break; case 5: if (m_kOldMailString.IsEmpty()) m_kOldMailString.Adopt(GetString(MOZ_UTF16("older"))); aValue.Assign(m_kOldMailString); break; default: NS_ASSERTION(false, "bad age thread"); break; } break; } case nsMsgViewSortType::bySubject: FetchSubject(msgHdr, m_flags[aRow], aValue); break; case nsMsgViewSortType::byAuthor: FetchAuthor(msgHdr, aValue); break; case nsMsgViewSortType::byStatus: rv = FetchStatus(m_flags[aRow], aValue); if (aValue.IsEmpty()) { tmp_str.Adopt(GetString(MOZ_UTF16("messagesWithNoStatus"))); aValue.Assign(tmp_str); } break; case nsMsgViewSortType::byTags: rv = FetchTags(msgHdr, aValue); if (aValue.IsEmpty()) { tmp_str.Adopt(GetString(MOZ_UTF16("untaggedMessages"))); aValue.Assign(tmp_str); } break; case nsMsgViewSortType::byPriority: FetchPriority(msgHdr, aValue); if (aValue.IsEmpty()) { tmp_str.Adopt(GetString(MOZ_UTF16("noPriority"))); aValue.Assign(tmp_str); } break; case nsMsgViewSortType::byAccount: FetchAccount(msgHdr, aValue); break; case nsMsgViewSortType::byRecipient: FetchRecipients(msgHdr, aValue); break; case nsMsgViewSortType::byAttachments: tmp_str.Adopt(GetString(flags & nsMsgMessageFlags::Attachment ? MOZ_UTF16("attachments") : MOZ_UTF16("noAttachments"))); aValue.Assign(tmp_str); break; case nsMsgViewSortType::byFlagged: tmp_str.Adopt(GetString(flags & nsMsgMessageFlags::Marked ? MOZ_UTF16("groupFlagged") : MOZ_UTF16("notFlagged"))); aValue.Assign(tmp_str); break; // byLocation is a special case; we don't want to have duplicate // all this logic in nsMsgSearchDBView, and its hash key is what we // want anyways, so just copy it across. case nsMsgViewSortType::byLocation: case nsMsgViewSortType::byCorrespondent: aValue = hashKey; break; case nsMsgViewSortType::byCustom: { nsIMsgCustomColumnHandler* colHandler = GetCurColumnHandlerFromDBInfo(); if (colHandler) { rv = colHandler->GetSortStringForRow(msgHdr.get(), aValue); break; } } default: NS_ASSERTION(false, "we don't sort by group for this type"); break; } if (groupThread) { // Get number of messages in group nsAutoString formattedCountMsg; uint32_t numMsg = groupThread->NumRealChildren(); formattedCountMsg.AppendInt(numMsg); // Get number of unread messages nsAutoString formattedCountUnrMsg; uint32_t numUnrMsg = 0; groupThread->GetNumUnreadChildren(&numUnrMsg); formattedCountUnrMsg.AppendInt(numUnrMsg); // Add text to header aValue.Append(NS_LITERAL_STRING(" (")); if (numUnrMsg) { aValue.Append(formattedCountUnrMsg); aValue.Append(NS_LITERAL_STRING("/")); } aValue.Append(formattedCountMsg); aValue.Append(NS_LITERAL_STRING(")")); } } else if (aColumnName[0] == 't' && aColumnName[1] == 'o') { nsAutoString formattedCountString; uint32_t numChildren = (groupThread) ? groupThread->NumRealChildren() : 0; formattedCountString.AppendInt(numChildren); aValue.Assign(formattedCountString); } return NS_OK; } return nsMsgDBView::CellTextForColumn(aRow, aColumnName, aValue); }