Enlightenment CVS committal

Author  : sarajervi
Project : misc
Module  : erss

Dir     : misc/erss/src


Modified Files:
        erss.c parse.c parse.h 


Log Message:
Added code to make sure the config file is valid. Also added description parsing, but 
it still has nowhere to display.
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/erss.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -3 -r1.1.1.1 -r1.2
--- erss.c      22 Dec 2003 15:17:29 -0000      1.1.1.1
+++ erss.c      22 Dec 2003 21:00:05 -0000      1.2
@@ -20,18 +20,24 @@
 
 int erss_connect (void *data)
 {
-       
-       if (!strcasecmp (cfg->proxy, "")) {
-               server = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
-                                                                                  
cfg->hostname, 80, NULL);
-       } else {
-               if (!cfg->proxy_port)
-               {
-                       fprintf (stderr, "ERROR: You need to define a proxy port!\n");
-                       exit (-1);
+       server = NULL;
+
+       if (cfg->proxy) {
+               if (!strcasecmp (cfg->proxy, "")) {
+                       server = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
+                                                                                      
          cfg->hostname, 80, NULL);
+               } else {
+                       if (!cfg->proxy_port)
+                       {
+                               fprintf (stderr, "ERROR: You need to define a proxy 
port!\n");
+                               exit (-1);
+                       }
+                       server = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
+                                                                                      
          cfg->proxy, cfg->proxy_port, NULL);
                }
+       } else {
                server = ecore_con_server_connect (ECORE_CON_REMOTE_SYSTEM,
-                                                                                  
cfg->proxy, cfg->proxy_port, NULL);
+                               cfg->hostname, 80, NULL);
        }
        
        if (!server) {
@@ -41,6 +47,8 @@
 
        if (last_time)
                free (last_time);
+       else
+               printf ("Erss: conneting to %s\n", cfg->url);
        
        last_time = strdup (time_format ());
        set_time (NULL);
@@ -103,7 +111,6 @@
 
        free (str);
 
-
        return TRUE;
 }
 
@@ -268,6 +275,11 @@
        Article *item = data;
        char c[1024];
 
+       if (!cfg->browser) {
+               fprintf (stderr, "Erss error: you have not defined any browser in your 
config file setting /usr/bin/mozilla as default\n");
+               cfg->browser = strdup ("/usr/bin/mozilla");
+       }
+       
        snprintf (c, sizeof (c), "%s %s", cfg->browser, item->url);
        ecore_exe_run (c, NULL);
 }
@@ -275,18 +287,14 @@
 void cb_mouse_in (void *data, Evas *e, Evas_Object *obj, 
                void *event_info) 
 {
-       printf ("In\n");
-       edje_object_signal_emit (obj, "over", "header");
+       
 }
 
 void cb_mouse_out (void *data, Evas *e, Evas_Object *obj, 
                void *event_info) 
 {
-       printf ("out\n");
-       edje_object_signal_emit (obj, "default", "header");
-} 
-
 
+} 
 
 
 int main (int argc, const char **argv)
@@ -304,6 +312,37 @@
        }
 
        parse_config_file ((char *) argv[1]);
+       
+       if (!cfg->hostname) {           
+               fprintf (stderr, "Erss error: No hostname defined!\n");
+               exit (-1);
+       }
+
+       if (!cfg->url) {
+               fprintf (stderr, "Erss error: No url defined!\n");
+               exit (-1);
+       }
+
+       if (!cfg->num_stories) {
+               fprintf (stderr, "Erss error: you need to define number "
+                               "of stories to display in your config file\n");
+               exit (-1);
+       }
+
+       if (!cfg->item_start) {
+               fprintf (stderr, "Erss error: you need to define item_start in your 
config file\n");
+               exit (-1);
+       }
+
+       if (!cfg->item_title) {
+               fprintf (stderr, "Erss error: you need to define item_title in your 
config file\n");
+               exit (-1);
+       }
+
+       if (!cfg->update_rate) {
+               fprintf (stderr, "Erss error: you need to define update_rate in your 
config file\n");
+               exit (-1);
+       }
 
        ecore_init ();
 
@@ -402,17 +441,6 @@
                e_container_element_append(cont, tid);
        }
 
-       if (!cfg->hostname) 
-       {               
-               fprintf (stderr, "ERROR: No hostname defined!\n");
-               exit (-1);
-       }
-
-       if (!cfg->url)
-       {
-               fprintf (stderr, "ERROR: No url defined!\n");
-               exit (-1);
-       }
        
        erss_connect (NULL);
        ecore_timer_add (cfg->update_rate, erss_connect, NULL); 
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/parse.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -3 -r1.1.1.1 -r1.2
--- parse.c     22 Dec 2003 15:17:31 -0000      1.1.1.1
+++ parse.c     22 Dec 2003 21:00:05 -0000      1.2
@@ -138,25 +138,32 @@
                 * We have a new story, allocate an item for it
                 */
                item = malloc (sizeof (Article *));
+               item->description = NULL;
+               item->url = NULL;
 
                return;
        }
 
        if (get_end_story (buf))
        {
+               /*
+               if (item->description)
+                       printf ("[%s]\n", item->description);
+               */
                
-                ewd_list_append (list, item);
+               ewd_list_append (list, item);
 
-                return;
+               return;
        }
 
+       /* If the item is not allocated then we dont have a 
+        * real story. So return with an error
+        */
+       if (!item)
+               return;
+
        if ((c = get_element (&buf, cfg->item_title)) != NULL)
        {
-               /* If the item is not allocated then we dont have a 
-                * real story. So return with an error
-                */
-               if (!item)
-                       return;
 
                for (i = 0; i < 2; i++)
                        c = remove_garbage (c, garbage[i]);
@@ -189,13 +196,12 @@
 
                free (c);
                free (text);
+
+               return; 
        }
 
        if ((c = get_element (&buf, cfg->item_url)) != NULL)
        {
-               if (!item)
-                       return;
-
                item->url = strdup (c);
 
                edje_object_signal_callback_add (item->obj, "exec*", "*", 
@@ -204,7 +210,18 @@
                edje_object_signal_emit (item->obj, "mouse,out", "article");
 
                free (c);
+               return;
        }
+
+       if ((c = get_element (&buf, cfg->item_description)) != NULL)
+       {
+               item->description = strdup (c);
+               
+               free (c);
+               return;
+       }
+
+       
 }
 
 char *get_next_line (FILE * fp)
@@ -288,6 +305,12 @@
                if ((c = get_element (&line, "item_url")) != NULL)
                {
                        cfg->item_url = strdup (c);
+                       continue;
+               }
+
+               if ((c = get_element (&line, "item_description")) != NULL)
+               {
+                       cfg->item_description = strdup (c);
                        continue;
                }
 
===================================================================
RCS file: /cvsroot/enlightenment/misc/erss/src/parse.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -3 -r1.1.1.1 -r1.2
--- parse.h     22 Dec 2003 15:17:31 -0000      1.1.1.1
+++ parse.h     22 Dec 2003 21:00:05 -0000      1.2
@@ -2,6 +2,7 @@
        Evas_Object *obj;
 
        char *url;
+       char *description;
 } Article;
 
 typedef struct _config {
@@ -12,6 +13,7 @@
        char *item_start;
        char *item_title;
        char *item_url;
+       char *item_description;
 
        int update_rate;
        int clock;




-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id=1278&alloc_id=3371&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to