Changeset 15709


Ignore:
Timestamp:
05/14/12 20:45:22 (11 years ago)
Author:
nit
Message:

[titan] add write to stock/weather

Location:
titan/plugins
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • titan/plugins/stock/stock.h

    r15707 r15709  
    6262                {
    6363                        changetext(tmp, fileline);
     64                        changename(tmp, fileline);
    6465                        if(name == NULL)
    6566                                name = ostrcat(name, fileline, 1, 0);
     
    170171
    171172        name = readstock(getconfig("stockfile", NULL), stock, listbox);
     173        addscreenrc(stock, listbox);
    172174
    173175start:
     
    244246        }
    245247
    246         addscreenrc(stock, listbox);
    247248        drawscreen(stock, 0);
    248249
     
    260261      if(name != NULL)
    261262      {
    262                                 freestock(node); node = NULL;
    263                                 goto start;
     263                                struct skin* tmp = addlistbox(stock, listbox, NULL, 1);
     264                                if(tmp != NULL)
     265                                {
     266                                        changetext(tmp, location);
     267                                        changename(tmp, location);
     268                                }
    264269      }
    265270      drawscreen(stock, 0);
    266       continue;
     271                        if(name == NULL)
     272                                continue;
     273                        free(name); name = NULL;
    267274    }
     275
     276                if(rcret == getrcconfigint("rcyellow", NULL))
     277                {
     278                        writestock(getconfig("stockfile", listbox);
     279                        continue;
     280                }
     281
     282                if(listbox->select != NULL && rcret == getrcconfigint("rcgreen", NULL))
     283                {
     284                        delscreennode(stock, listbox->select->name);
     285                        drawscreen(stock, 0);
     286                }
    268287   
    269288    if(rcret == getrcconfigint("rcgreen", NULL) && node->symbol_lookup_url != NULL)
     
    302321}
    303322
     323int writestock(const char *filename, struct skin* listbox)
     324{
     325        debug(1000, "in");
     326        FILE *fd = NULL;
     327        struct skin* node = listbox;
     328        int ret = 0;
     329
     330        fd = fopen(filename, "w");
     331        if(fd == NULL)
     332        {
     333                perr("can't open %s", filename);
     334                return 1;
     335        }
     336
     337        while(node != NULL)
     338        {
     339                if(node->del == 1)
     340                {
     341                        ret = fprintf(fd, "%s\n", node->text);
     342                        if(ret < 0)
     343                        {
     344                                perr("writting file %s", filename);
     345                        }
     346                }
     347                node = node->next;
     348        }
     349
     350        fclose(fd);
     351        debug(1000, "out");
     352        return 0;
     353}
     354
    304355#endif
  • titan/plugins/weather/weather.h

    r15707 r15709  
    6969                {
    7070                        changetext(tmp, fileline);
     71                        changename(tmp, fileline);
    7172                        if(location == NULL)
    7273                                location = ostrcat(location, fileline, 1, 0);
     
    297298
    298299        location = readweather(getconfig("weatherfile", NULL), weather, listbox);
     300        addscreenrc(weather, listbox);
    299301
    300302start:
     
    385387        }
    386388
    387         addscreenrc(weather, listbox);
    388389        drawscreen(weather, 0);
    389390
     
    401402      if(location != NULL)
    402403      {
    403                                 freeweather(node); node = NULL;
    404                                 goto start;
     404                                struct skin* tmp = addlistbox(weather, listbox, NULL, 1);
     405                                if(tmp != NULL)
     406                                {
     407                                        changetext(tmp, location);
     408                                        changename(tmp, location);
     409                                }
    405410      }
    406411      drawscreen(weather, 0);
    407       continue;
     412                        if(location == NULL)
     413                                continue;
     414                        free(location); location = NULL;
    408415    }
     416
     417                if(rcret == getrcconfigint("rcyellow", NULL))
     418                {
     419                        writeweather(getconfig("weatherfile", listbox);
     420                        continue;
     421                }
     422
     423                if(listbox->select != NULL && rcret == getrcconfigint("rcgreen", NULL))
     424                {
     425                        delscreennode(weather, listbox->select->name);
     426                        drawscreen(weather, 0);
     427                }
    409428
    410429                if(listbox->select != NULL)
     
    422441}
    423442
     443int writeweather(const char *filename, struct skin* listbox)
     444{
     445        debug(1000, "in");
     446        FILE *fd = NULL;
     447        struct skin* node = listbox;
     448        int ret = 0;
     449
     450        fd = fopen(filename, "w");
     451        if(fd == NULL)
     452        {
     453                perr("can't open %s", filename);
     454                return 1;
     455        }
     456
     457        while(node != NULL)
     458        {
     459                if(node->del == 1)
     460                {
     461                        ret = fprintf(fd, "%s\n", node->text);
     462                        if(ret < 0)
     463                        {
     464                                perr("writting file %s", filename);
     465                        }
     466                }
     467                node = node->next;
     468        }
     469
     470        fclose(fd);
     471        debug(1000, "out");
     472        return 0;
     473}
     474
    424475#endif
Note: See TracChangeset for help on using the changeset viewer.