home *** CD-ROM | disk | FTP | other *** search
- #include "defs.h"
- #include "memalloc.h"
-
- // #define PROCDEBUG
-
- #ifdef PROCDEBUG
- #define D(x) printf x
- #else
- #define D(x)
- #endif
-
- extern char *NewsGroupToFileName (char *newsgroup);
-
- static LIST nullList;
- GLIST *currentGroup = 0;
-
- ULONG totalGroups = 0, totalArticles = 0, unreadArticles = 0;
-
- /************************************************************************/
-
- /*
- * As each gadget in the GadDefs array above is created, it is assigned a UserID
- * field value, incremented from zero. The following defines are useful for switch
- * statements, etc. Enum would also work. Be careful, if you add new gadgets in
- * the middle of the initializations above, because you will need to renumber these
- * defines.
- */
- static enum GADGET_IDS {
- GROUPLIST_ID,
- QUIT_ID,
- READ_ID,
- POST_ID,
- CATCHUP_ID,
- PUBLISH_ID,
- JUNK_ID,
- BUGREPORT_ID,
- UUCPBUG_ID,
- STATUS_ID,
- MAXGADGET,
- };
-
- static GADGET *gadgetArray[MAXGADGET];
-
- /*
- * Misc tags arrays
- */
- static TAGS nullTags[] = { GT_Underscore, '_', TAG_DONE,0 };
- static TAGS disableTags[] = { GT_Underscore, '_', GA_Disabled,TRUE, TAG_DONE,0 };
- static TAGS enableTags[] = { GT_Underscore, '_', GA_Disabled,FALSE, TAG_DONE,0 };
-
- static TAGS groupListTags[] = {
- GT_Underscore, '_',
- GTLV_Top, 0,
- GTLV_Labels, &groupList,
- GTLV_ReadOnly, FALSE,
- GTLV_ScrollWidth, 16,
- GTLV_ShowSelected, NULL,
- GTBB_Recessed, FALSE,
- TAG_DONE, 0,
- };
-
- static TAGS nullListTags[] = {
- GT_Underscore, '_',
- GTLV_Top, 0,
- GTLV_Labels, &nullList,
- GTLV_ReadOnly, FALSE,
- GTLV_ScrollWidth, 16,
- GTBB_Recessed, FALSE,
- TAG_DONE, 0,
- };
-
- static char *nullText = "";
- static TAGS textTags[] = {
- GT_Underscore, '_',
- GTTX_Text, (ULONG)"",
- GTTX_CopyText, TRUE,
- GTTX_Border, TRUE,
- TAG_DONE, 0,
- };
-
- /*
- * The Array of Gadget definitions. To create a new gadget, add an initializer
- * here, and create the necessary tags...
- */
- static GADDEF gadDefs[] = {
- groupListTags, LISTVIEW_KIND,0,0,0,0, NG_HIGHLABEL, "",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_Quit",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_Read",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_Post",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_Catch up",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "Publish",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_Junk",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_Bug Report",
- enableTags, BUTTON_KIND, 0,0,0,0, NG_HIGHLABEL, "_UUCP Bug Report",
- textTags, TEXT_KIND, 0,0,0,0, NG_HIGHLABEL, "",
- 0,0,0,0,0,0,0,0,
- };
-
- static GADGET *gList = 0;
-
- static void LayoutGadgets(font,width,height,top)
- FONT *font;
- short width,height,top;
- {
- short i, x,y, fh;
- RPORT rPort, *rp = &rPort;
-
- InitRastPort(rp);
- SetFont(rp, font);
- y = top+INTERHEIGHT/2;
-
- fh = rp->TxHeight+2;
- gadDefs[GROUPLIST_ID].left = INTERWIDTH;
- gadDefs[GROUPLIST_ID].top = y;
- gadDefs[GROUPLIST_ID].width = width-INTERWIDTH-INTERWIDTH;
- gadDefs[GROUPLIST_ID].height = 12*fh+INTERHEIGHT;
- y += 12*fh+INTERHEIGHT;
-
- fh = topazRP->TxHeight+2;
- x = INTERWIDTH;
- for (i=QUIT_ID; i<=UUCPBUG_ID; i++) {
- gadDefs[i].left = x;
- gadDefs[i].top = y;
- gadDefs[i].width = TextLen(topazRP, gadDefs[i].text)+8;
- gadDefs[i].height = fh+2;
- x += gadDefs[i].width + INTERWIDTH;
- }
- y += fh+INTERHEIGHT+fh+INTERHEIGHT+fh+INTERHEIGHT;
- y += height-y-fh-fh-INTERHEIGHT-4;
-
- gadDefs[STATUS_ID].left = INTERWIDTH;
- gadDefs[STATUS_ID].top = y;
- gadDefs[STATUS_ID].width = width-INTERWIDTH-INTERWIDTH;
- gadDefs[STATUS_ID].height = fh+2;
- y += fh+4;
-
- return;
- }
-
- /************************************************************************/
-
- void CloseGroups (void)
- {
- if (!gList)
- return;
- if (RemoveGList (mainWindow, gList, -1) == -1) {
- t_printf (mainWindow, "RemoveGList() failed!");
- return;
- }
- FreeGadgets (gList);
- gList = 0;
- ClearWindow ();
- return;
- }
-
- void GroupsStatus (void)
- {
- GLIST *gp;
- ART *ap;
- static char groupStatus [256];
-
- totalGroups = 0;
- totalArticles = 0;
- unreadArticles = 0;
- for (gp=(GLIST *)groupList.lh_Head; gp->node.ln_Succ; gp=(GLIST *)gp->node.ln_Succ) {
- gp->articles = 0;
- gp->unread = 0;
- totalGroups++;
- for (ap=(ART *)gp->artList.lh_Head; ap->node.ln_Succ; ap = (ART *)ap->node.ln_Succ) {
- totalArticles++; gp->articles++;
- if (ap->state == UNREAD) {
- unreadArticles++;
- gp->unread++;
- }
- }
- sprintf(gp->header, "%-40.40s %6d articles %6d UnRead", gp->groupName, gp->articles, gp->unread);
- }
- sprintf (groupStatus, " *** %d groups, %d articles (%d unread)", totalGroups, totalArticles, unreadArticles);
- GT_SetGadgetAttrs (gadgetArray [STATUS_ID], mainWindow, NULL,
- GTTX_Text, groupStatus, TAG_DONE);
- return;
- }
-
- UWORD GroupID (void)
- {
- UWORD n;
- GLIST *gp = (GLIST *)groupList.lh_Head;
- n = 0;
- while (gp->node.ln_Succ) {
- if (gp == currentGroup) return n;
- gp = (GLIST *)gp->node.ln_Succ;
- n++;
- }
- return ~0;
- }
-
- static void ValidateOptions (void)
- {
- int i;
-
- if (!currentGroup) {
- for (i = READ_ID; i <= PUBLISH_ID; i++) {
- GT_SetGadgetAttrs (gadgetArray [i], mainWindow, NULL,
- GA_Disabled, TRUE, TAG_DONE);
- }
- return;
- }
- if (currentGroup->articles == 0) {
- GT_SetGadgetAttrs (gadgetArray [READ_ID], mainWindow, NULL,
- GA_Disabled, TRUE, TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [CATCHUP_ID], mainWindow, NULL,
- GA_Disabled, TRUE, TAG_DONE);
- return;
- }
- if (currentGroup->unread == 0) {
- GT_SetGadgetAttrs (gadgetArray [READ_ID], mainWindow, NULL,
- GA_Disabled, FALSE, TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [CATCHUP_ID], mainWindow, NULL,
- GA_Disabled, TRUE, TAG_DONE);
- return;
- }
- for (i = READ_ID; i <= PUBLISH_ID; i++) {
- GT_SetGadgetAttrs (gadgetArray [i], mainWindow, NULL,
- GA_Disabled, FALSE, TAG_DONE);
- }
- return;
- }
-
- /************************************************************************/
-
- // Junk an existing newsgroup
- //
- // This only involves removing the group (and its articles) from the newstree
- // THEY WILL STAY IN THE UUNEWS: DIRECTORY
- //
- void Junk (BOOL flag)
- {
- ART *ap;
- GLIST *gp;
-
- D (("Junk(): enter\n"));
-
- if (flag && TwoGadgetRequest ("GRn - Request",
- "Remove this group from your Active list?",
- "_YES", "_NO") == 0) {
-
- D (("Junk(): non confirm, exit\n"));
- return;
- }
-
- while (!EmptyList (¤tGroup->artList)) {
- ap = (ART *) RemHead (¤tGroup->artList);
- FreeART (ap);
- }
-
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Labels, ~0, TAG_DONE);
-
- gp = (groupList.lh_TailPred == (NODE *)currentGroup) ? (GLIST *)groupList.lh_Head : (GLIST *)currentGroup->node.ln_Succ;
- Remove ((NODE *) currentGroup);
- FreeNODE (currentGroup);
- currentGroup = gp;
-
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Labels, &groupList, TAG_DONE);
-
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Selected, GroupID(), TAG_DONE);
-
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Top, GroupID(), TAG_DONE);
-
- treeDirty = !0;
-
- D (("Junk(): exit\n"));
- return;
- }
-
- /************************************************************************/
-
- void AppendSignature (int outfd)
- {
- int fd;
- int len;
- char *temp, *work;
-
- D (("AppendSignature(): enter\n"));
-
- if (outfd < 0)
- return;
- if (!(temp = malloc (256))) {
- t_printf (mainWindow, "Can't malloc 256 bytes for signature");
-
- D (("AppendSignature(): get mem failure 1, exit\n"));
- return;
- }
- if (!(work = malloc (256))) {
- t_printf (mainWindow, "Can't malloc 256 bytes for signature");
- free (temp);
-
- D (("AppendSignature(): get mem failure 2, exit\n"));
- return;
- }
-
- strcpy (temp, uulib);
- CopyStrings (work, userName, ".signature", NULL);
- AddPart (temp, work, 256);
- if ((fd = open (temp, O_RDONLY)) < 0) {
- strcpy (temp, uulib);
- AddPart (temp, ".signature", 256);
- fd = open (temp, O_RDONLY);
- }
- if (fd < 0) {
- OutputStrings (outfd, ".signature under construction\n", NULL);
- }
- else {
- while ((len = read (fd, temp, 256)) > 0)
- write (outfd, temp, len);
- close (fd);
- }
-
- free (work);
- free (temp);
-
- D (("AppendSignature(): exit\n"));
- return;
- }
-
- void AppendNewsGroupSignature (int outfd)
- {
- int fd;
- int len;
- char *work, *temp;
-
- D (("AppendNewsGroupSignature(): enter\n"));
-
- if (outfd < 0)
- return;
- if (!(work = malloc (256))) {
- t_printf (mainWindow, "Can't malloc 256 bytes for signature");
-
- D (("AppendNewsGroupSignature(): get mem failure 1\n"));
- return;
- }
- if (!(temp = malloc (256))) {
- t_printf (mainWindow, "Can't malloc 256 bytes for signature");
- free (work);
-
- D (("AppendNewsGroupSignature(): get mem failure 2\n"));
- return;
- }
-
- strcpy (temp, uulib);
- CopyStrings (work, userName, ".signature", NULL);
- AddPart (temp, work, 256);
-
- if (currentGroup && (fd = open (temp, O_RDONLY)) < 0) {
- strcpy (temp, uunews);
- AddPart (temp, NewsGroupToFileName (currentGroup->groupName),
- 256);
- AddPart (temp, work, 256);
- fd = open (temp, O_RDONLY);
- }
- if (fd < 0) {
- strcpy (temp, uulib);
- AddPart (temp, ".signature", 256);
- fd = open (temp, O_RDONLY);
- }
- if (fd < 0) {
- OutputStrings (outfd, ".signature under construction\n", NULL);
- }
- else {
- while ((len = read (fd, temp, 256)) > 0)
- write (outfd, temp, len);
-
- close (fd);
- }
-
- free (temp);
- free (work);
-
- D (("AppendNewsGroupSignature(): exit\n"));
- return;
- }
-
- void BugReport (void)
- {
- int outfd;
- char *fname;
-
- D (("BugReport(): enter\n"));
-
- fname = TempName ();
- if ((outfd = creat (fname, 0660)) < 0) {
- t_printf (mainWindow, "Can't open %s for output", fname);
-
- D (("BugReport(): open output failure, exit\n"));
- return;
- }
- // To: grnbugs@amiga0.sf-bay.org
- OutputStrings (outfd, "To: grnbugs@adastra.cvl.va.us\n",
- "Subject: Bug Report For ",
- GRN_VERSION,
- "\n"
- "X-NewsSoftware: ",
- GRN_VERSION,
- "\n\n\n-- \n",
- NULL);
-
- AppendSignature (outfd);
- close (outfd);
-
- SendMail (fname);
-
- GT_RefreshWindow (mainWindow, NULL);
-
- D (("BugReport(): exit\n"));
- return;
- }
-
- /************************************************************************/
-
- void UUCPBugReport (void)
- {
- int outfd;
- char *fname;
- char *ptr;
-
- D (("UUCPBugReport(): enter\n"));
-
- ptr = TempName ();
- if ((outfd = creat (ptr, 0660)) < 0) {
- t_printf (mainWindow, "Can't open %s for output", fname);
-
- D (("UUCPBugReport(): open output failure, exit\n"));
- return;
- }
- fname = malloc (strlen (ptr) + 1);
- if (!fname) {
- t_printf (mainWindow, "Can't malloc() memory for filename");
- close (outfd);
-
- D (("UUCPBugReport(): get mem failure, exit\n"));
- return;
- }
- strcpy (fname, ptr);
-
- OutputStrings (outfd,
- "Newsgroups: alt.sys.amiga.uucp\n",
- "Subject: UUCP Bug report from GRn\n",
- "Distribution: world\n\n",
- "##B <personal identifier>\n\n",
- "The above <personal identifier> is for the\n",
- "bug reporter to use for whatever internal tracking he wants\n",
- "to do (it must be unique on a person by person basis).\n",
- "\n##\n",
- "\n-- \n",
- NULL);
-
- AppendSignature (outfd);
- close (outfd);
-
- PostNews (0, fname);
- free (fname);
-
- GT_RefreshWindow (mainWindow, NULL);
-
- D (("UUCPBugReport(): exit\n"));
- return;
- }
-
- /************************************************************************/
-
- void Catchup (void)
- {
- ART *ap;
-
- if (!currentGroup)
- return;
- currentGroup->articles = currentGroup->unread = 0;
- for (ap = (ART *) currentGroup->artList.lh_Head; ap->node.ln_Succ; ap = (ART *) ap->node.ln_Succ) {
- ap->state = READ;
- currentGroup->articles++;
- treeDirty = !0;
- }
- }
-
- /************************************************************************/
-
- void Publish (void)
- {
- char temp [512], work [256];
- STRPTR filename;
- FILE *infp, *fp;
- UWORD i, line; long rslt, len;
- char *partname; // temporary file name for this part
- char *inname; // file to be published (provided by user)
- char *outname; // uuencoded output file (generated by GRn)
- long lineCount = 0; // number of lines in uuencoded file
- long parts; // how many articles will it take to publish file
- long part; // current article
- int fd; // input file descriptor
- int outfd; // output file descriptor
- char *p, *ptr; // temporaries
-
- D (("Publish(): enter\n"));
-
- if (!AslRequestTags (publishReq, TAG_DONE)) {
- D (("Publish(): AslRequestTags() failure, exit\n"));
- return;
- }
- i = strlen (publishReq->rf_Dir) + strlen (publishReq->rf_File) + 10;
- if (!(inname = malloc (i))) {
- t_printf (mainWindow, "Can't malloc %d bytes for filename", i);
-
- D (("Publish(): exit, get mem failure 1\n"));
- return;
- }
- strcpy (inname, publishReq->rf_Dir);
- AddPart (inname, publishReq->rf_File, i);
- D (("Publish(): inname = '%s'\n", inname));
-
- if (!SendItRequest ()) {
- free (inname);
-
- D (("Publish(): exit, SendItRequest said no\n"));
- return;
- }
-
- p = TempName ();
- outname = malloc (strlen (p) + 1);
- if (!outname) {
- t_printf (mainWindow, "Can't get memory for filename");
- free (inname);
-
- D (("Publish(): exit, get mem failure 2\n"));
- return;
- }
- strcpy (outname, p);
- D (("Publish(): outname = '%s'\n", outname));
-
- filename = FilePart (inname);
- CopyStrings (work, "uuencode ", inname, " ", filename, " >", outname, NULL);
- D (("Publish(): uuencode string = '%s'\n", work));
-
- t_printf (mainWindow, "GRn - UUEncoding %s", filename);
-
- rslt = SystemTags (work, SYS_Input, 0,
- SYS_Output, 0,
- SYS_Asynch, 0, // NP_Synchronous, 1,
- NP_StackSize, 32000,
- TAG_DONE);
- if (rslt != 0) {
- strcpy (temp, "GRn - Your UUEncode had a return value of ");
- strcat (temp, itoa (rslt));
- if (TwoGadgetRequest (temp,
- "It may not have completed normally. Shall I continue?",
- "_Yes", "_No") == 0) {
- remove (outname);
- free (outname);
- free (inname);
-
- D (("Publish(): exit, bad uuencode\n"));
- return;
- }
- }
-
- // find the numbers of lines in the uuencoded file
- if ((fd = open (outname, O_RDONLY)) < 0) {
- OneGadgetRequest ("GRn Error", "Can't open uuencoded file", "Cancel Publish");
- free (inname);
- free (outname);
-
- D (("Publish(): exit, missing uuencoded file\n"));
- return;
- }
- while (i = read (fd, temp, 512)) {
- p = temp;
- while (i--) {
- if (*p == '\n')
- lineCount++;
- p++;
- }
- }
- close (fd);
-
- // calculate the number of postings required...
- parts = (lineCount + 499) / 500;
-
- // FIXME: remove this last piece of STDIO (use of infp)
-
- if (!(infp = fopen (outname, "r"))) {
- OneGadgetRequest ("GRn Error", "Can't open uuencoded file", "Cancel Publish");
- free (inname);
- free (outname);
-
- D (("Publish(): exit, missing uuencoded file 2\n"));
- return;
- }
-
- line = 0;
- for (part = 1; part <= parts; part++) {
- t_printf (mainWindow, "Publishing part %d of %d", part, parts);
- partname = TempName ();
- if ((outfd = creat (partname, 0660)) < 0) {
- fclose(infp);
- free (inname);
- free (outname);
- OneGadgetRequest("GRn Error", "Can't open uuencoded file", "Cancel Publish");
-
- D (("Publish(): exit, open output failure\n"));
- return;
- }
- OutputStrings (outfd, "Newsgroups: ", currentGroup->groupName,
- "\n", NULL);
- OutputStrings (outfd, "Subject: Posting of ",
- filename,
- " (Part ",
- itoa (part),
- "/",
- itoa (parts),
- ")\n",
- NULL);
-
- // FIXME - this should be configurable!
- OutputStrings (outfd, "Distribution: world\n\n", NULL);
-
- CopyStrings (work, "Posting ", filename, " in ", itoa (parts),
- " parts", NULL);
-
- for (i = 0; line < lineCount && i < 500; i++, line++) {
- // should we let the user cancel the process?
- GuageRequest ((100 * line) / lineCount,
- "GRn - Publishing",
- work,
- "Wait");
- if (!fgets (temp, 512, infp)) {
- line = lineCount;
- part = parts + 1;
- break;
- }
- OutputStrings (outfd, temp, NULL);
- }
- OutputStrings (outfd, "\n--\n", NULL);
-
- AppendNewsGroupSignature (outfd);
- close (outfd);
-
- PostNews (-1, partname); // tell'em not to let user edit.
-
- GT_RefreshWindow (mainWindow, NULL);
- }
-
- GuageRequest (1000, "GRn - Publishing", work, "Wait");
- fclose (infp);
- free (inname);
- free (outname);
-
- t_printf (mainWindow, "GRn - News Directory");
-
- GT_RefreshWindow (mainWindow, NULL);
-
- D (("Publish(): exit\n"));
- return;
- }
-
- /************************************************************************/
-
- /*
- * void ProcessGadget(id, code);
- * UWORD id; gadgetID of gadget to process
- * UWORD code; IntuiMessage Code
- *
- * Synopsis:
- * Process IDCMP message for GadTools gadget. Simply prints an appropriate string
- * into the event listview, unless it is palette related (handles palette appropriately).
- */
- static void ProcessGadget (UWORD id, UWORD code) {
- /* GADGET *gad = gadgetArray[id]; */
- GLIST *gp;
-
- D (("ProcessGadget(): enter, Group Mode\n"));
-
- switch (id) {
- case GROUPLIST_ID:
- gp = (GLIST *) FindListItem (&groupList, code);
- if (gp == currentGroup) {
- mode = ARTICLES_MODE;
- break;
- }
- if (!gp) {
- t_printf (mainWindow, "Error: Can't FindListItem (%d)\n", code);
- break;
- }
- currentGroup = gp;
- ValidateOptions ();
- break;
-
- case QUIT_ID:
- mode = QUIT_MODE;
- break;
-
- case READ_ID:
- mode = ARTICLES_MODE;
- break;
-
- case CATCHUP_ID:
- Catchup ();
- GroupsStatus ();
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Labels, ~0, TAG_DONE);
- sprintf (currentGroup->header, "%-40.40s %6d articles %6d UnRead",
- currentGroup->groupName,
- currentGroup->articles,
- currentGroup->unread
- );
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Labels, &groupList, TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Selected, GroupID (), TAG_DONE);
- break;
-
- case POST_ID:
- Post (FALSE);
- break;
-
- case BUGREPORT_ID:
- BugReport ();
- break;
-
- case JUNK_ID:
- Junk (!0);
- break;
-
- case PUBLISH_ID:
- Publish ();
- break;
-
- case UUCPBUG_ID:
- UUCPBugReport ();
- break;
-
- default:
- t_printf (mainWindow, "ProcessGadget - id = %d", id);
- break;
- }
-
- D (("ProcessGadget(): exit, Group Mode\n"));
- return;
- }
-
- static void IDCMPFunc (IMSG *m)
- {
- GLIST *NextGroup (), *PrevGroup ();
-
- D (("IDCMPFunc(): enter, Group Mode\n"));
-
- switch (m->Class) {
- case IDCMP_CLOSEWINDOW:
- mode = ABORT_MODE;
- break;
-
- case IDCMP_VANILLAKEY:
- switch (m->Code) {
- case 'Q':
- mode = QUIT_MODE;
- break;
-
- case 'R':
- if (currentGroup->articles)
- mode = ARTICLES_MODE;
- break;
-
- case 'P':
- Post (FALSE);
- break;
-
- case 'C':
- if (currentGroup->unread) {
- Catchup ();
- GroupsStatus ();
- GT_SetGadgetAttrs (gadgetArray[GROUPLIST_ID], mainWindow, NULL, GTLV_Labels, ~0, TAG_DONE);
- sprintf (currentGroup->header, "%-40.40s %6d articles %6d UnRead",
- currentGroup->groupName,
- currentGroup->articles,
- currentGroup->unread
- );
- GT_SetGadgetAttrs (gadgetArray[GROUPLIST_ID], mainWindow, NULL, GTLV_Labels, &groupList, TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray[GROUPLIST_ID], mainWindow, NULL, GTLV_Selected, GroupID(), TAG_DONE);
- }
- break;
-
- case 'B':
- BugReport ();
- break;
-
- case 'J':
- Junk (0);
- break;
-
- case 'U':
- UUCPBugReport ();
- break;
- }
- break;
-
- case IDCMP_RAWKEY:
- switch (m->Code) {
- case 0x4c: // up key
- currentGroup = PrevGroup ();
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL, GTLV_Selected, GroupID(), TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL, GTLV_Top, GroupID(), TAG_DONE);
- break;
- case 0x4d: // down key
- currentGroup = NextGroup ();
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL, GTLV_Selected, GroupID(), TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL, GTLV_Top, GroupID(), TAG_DONE);
- break;
- }
- default:
- break;
- }
-
- D (("IDCMPFunc(): exit, Group Mode\n"));
- return;
- }
-
- void GroupsWindow (void)
- {
- D (("GroupsWindow(): enter\n"));
-
- if (!currentGroup)
- currentGroup = (GLIST *)groupList.lh_Head;
- if (mode == NEXTGROUPS_MODE || mode == PREVGROUPS_MODE) {
- mode = ARTICLES_MODE;
- return;
- }
- NewList (&nullList);
- LayoutGadgets (defaultFont, prefWidth,windowHeight, screenTop);
- gList = CreateGadgets (gadgetArray, gadDefs);
- AddGList (mainWindow, gList, -1, -1, 0);
- RefreshGList (gList, mainWindow, 0, -1);
- GT_RefreshWindow (mainWindow, NULL);
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Labels, ~0, TAG_DONE);
- GroupsStatus ();
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Labels, &groupList, TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Selected, GroupID (), TAG_DONE);
- GT_SetGadgetAttrs (gadgetArray [GROUPLIST_ID], mainWindow, NULL,
- GTLV_Top, GroupID(), TAG_DONE);
- ValidateOptions ();
- t_printf (mainWindow, "GRn - News Directory");
- while (mode == GROUPS_MODE) {
- WaitPort (mainWindow->UserPort);
- EventHandler (mainWindow, ProcessGadget, IDCMPFunc, NULL);
- }
- CloseGroups ();
-
- D (("GroupsWindow(): exit\n"));
- return;
- }
-