Changeset 560

Show
Ignore:
Timestamp:
04/30/08 01:07:04 (2 weeks ago)
Author:
agr
Message:

NRK REBOOT ON ERROR fix

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • nano-RK/projects/SAMPL/slip-clients/xmpp-client/lm-library.c

    r489 r560  
    11#include "lm-library.h" 
    22 
    3 //#define LM_LIBRARY_DEBUG 
     3//#define SSL_ERRORS 
     4 
     5#define PUBSUB_NS "http://jabber.org/protocol/pubsub" 
     6#define DEFAULT_RESOURCE "server-test" 
    47 
    58static GMainLoop *main_loop = NULL; 
     
    177180        gpointer     ud) 
    178181{ 
    179   //g_print ("XMPP_Client: SSL status:%d\n", status); 
    180    
     182#ifdef DEBUG 
     183  g_print ("XMPP_Client: SSL status:%d\n", status); 
     184#endif 
     185   
     186#ifdef SSL_ERRORS 
    181187  switch (status) { 
    182188  case LM_SSL_STATUS_NO_CERT_FOUND: 
     
    204210    break; 
    205211  } 
    206    
     212#endif   
     213 
    207214  return LM_SSL_RESPONSE_CONTINUE; 
    208215} 
     
    215222  if (success) { 
    216223    LmMessage *m; 
    217      
     224 
     225#ifdef DEBUG 
    218226    g_print ("XMPP_Client: Authenticated successfully\n"); 
     227#endif 
    219228 
    220229    init_success = TRUE; 
     
    224233                                      LM_MESSAGE_SUB_TYPE_AVAILABLE); 
    225234    lm_connection_send (connection, m, NULL); 
    226     //g_print ("XMPP_Client: Sent presence message:'%s'\n", lm_message_node_to_string (m->node)); 
    227      
     235 
     236#ifdef DEBUG 
     237    g_print ("XMPP_Client: Sent presence message:'%s'\n", lm_message_node_to_string (m->node)); 
     238#endif 
     239 
    228240    lm_message_unref (m); 
    229241 
     
    250262                                NULL, FALSE,  NULL); 
    251263    g_free (user); 
    252      
    253     //g_print ("XMPP_Client: Sent authentication message\n"); 
     264 
     265#ifdef DEBUG     
     266    g_print ("XMPP_Client: Sent authentication message\n"); 
     267#endif 
     268 
    254269  } else { 
    255270    g_printerr ("XMPP_Client: Failed to connect\n"); 
     
    293308                 gpointer          user_data) 
    294309{ 
    295   /* 
    296   g_print ("XMPP_Client: Incoming message from: %s <type=%s subtype=%s>\n", 
    297            lm_message_node_get_attribute (m->node, "from"), 
    298            m->node->name, 
    299            lm_message_node_get_attribute(m->node,"type")); 
    300   */ 
     310   
     311  //g_print ("XMPP_Client: Incoming message: %s\n",  
     312  //lm_message_node_to_string(m->node)); 
    301313 
    302314  if( (lm_message_get_type(m) == LM_MESSAGE_TYPE_MESSAGE) &&  
     
    307319} 
    308320 
    309  
    310321XMPPResult create_event_node (gchar *nodeID,  
    311322                              GSList *collectionList,  
    312323                              gboolean isCollection) 
     324{ 
     325  return create_event_node_with_desc (nodeID,"default",collectionList,isCollection); 
     326} 
     327 
     328 
     329XMPPResult create_event_node_with_desc (gchar *nodeID, 
     330                                        gchar *desc, 
     331                                        GSList *collectionList,  
     332                                        gboolean isCollection) 
    313333{ 
    314334  LmMessage *m,*reply; 
     
    344364                                     ')', 
    345365                                     ')', 
     366                                     '(', "field", "", 
     367                                     '@', "var", "pubsub#title", 
     368                                     '(', "value", desc, 
     369                                     ')', 
     370                                     ')', 
    346371                                     ')', 
    347372                                     ')', 
     
    481506   
    482507  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
    483    
     508 
    484509  lm_message_unref(m); 
    485510   
     
    543568                                     '@', "xmlns", "http://jabber.org/protocol/disco#items", 
    544569                                     ')', NULL); 
    545    
     570  
     571#ifdef DEBUG 
     572  g_print("Sending get_node_list msg:\n%s\n",lm_message_node_to_string(m->node)); 
     573#endif 
     574 
    546575  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
     576 
     577#ifdef DEBUG 
     578  g_print("Reply get_node_list msg:\n%s\n",lm_message_node_to_string(reply->node)); 
     579#endif 
    547580 
    548581  lm_message_unref (m);   
     
    559592    child = lm_message_node_find_child(reply->node,"query"); 
    560593    if(child == NULL) { 
    561       g_print("could not find query in msg\n"); 
     594      g_print("XMPP_Client: could not find query in msg\n"); 
    562595      lm_message_unref(reply); 
    563596      return NULL; 
     
    566599    child = child->children; 
    567600    if(child == NULL) { 
    568       g_print("no items in query result\n"); 
     601      g_print("XMPP_Client: no items in query result\n"); 
    569602      lm_message_unref(reply); 
    570603      return NULL; 
     
    573606    while(child != NULL) { 
    574607      NodeDesc *node = g_new0 (NodeDesc, 1); 
    575       node->name = (gchar*) lm_message_node_get_attribute(child,"node"); 
    576       node->desc = (gchar*) lm_message_node_get_attribute(child,"name"); 
     608      strcpy(node->name, (gchar*) lm_message_node_get_attribute(child,"node")); 
     609      strcpy(node->desc, (gchar*) lm_message_node_get_attribute(child,"name")); 
    577610      node_list = g_slist_prepend (node_list, node); 
    578611      child = child->next; 
     
    580613  } 
    581614  else { 
    582     g_print("Dont know how to handle message < %s , %s >\n",reply->node->name,lm_message_node_get_attribute(reply->node,"type")); 
     615    g_print("XMPP_Client: Dont know how to handle message < %s , %s >\n",reply->node->name,lm_message_node_get_attribute(reply->node,"type")); 
    583616    lm_message_unref(reply); 
    584617    return NULL; 
    585618  } 
    586619 
     620  lm_message_unref(reply); 
     621  return node_list; 
     622} 
     623 
     624GSList* get_all_current_subscriptions(void) 
     625{ 
     626  LmMessage *m, *reply; 
     627  GError *error = NULL; 
     628  GSList *node_list = NULL; 
     629  LmMessageNode *child = NULL; 
     630 
     631  if(connection == NULL) 
     632    return NULL; 
     633 
     634  m = lm_message_build_with_sub_type(_pubsub_server, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_SET, 
     635                                     '(', "pubsub", "", 
     636                                     '@', "xmlns", PUBSUB_NS, 
     637                                     '(', "subscriptions", "", 
     638                                     ')', 
     639                                     ')', NULL); 
     640 
     641  lm_message_node_set_attribute(m->node,"from",username); 
     642 
     643#ifdef DEBUG 
     644  g_print("get_all_subscriptions message: %s\n",lm_message_node_to_string(m->node)); 
     645#endif 
     646 
     647  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
     648 
     649#ifdef DEBUG 
     650  g_print("get_all_subscriptions reply: %s\n",lm_message_node_to_string(reply->node)); 
     651#endif 
     652 
     653  lm_message_unref (m); 
     654 
     655  if(error != NULL) { 
     656    g_printerr ("XMPP_Client: Failed to get all subscriptions: error:%d->'%s'\n",error->code,error->message); 
     657    g_free(error); 
     658    goto finish; 
     659     
     660    //lm_message_unref(reply); 
     661    //return NULL; 
     662  } 
     663 
     664  if(lm_message_get_type(reply) == LM_MESSAGE_TYPE_IQ && lm_message_get_sub_type(reply) == LM_MESSAGE_SUB_TYPE_ERROR) { 
     665    LmMessageNode *child = lm_message_node_find_child(reply->node,"error"); 
     666    const gchar* attr = lm_message_node_get_attribute(child,"type"); 
     667     
     668    g_printerr ("get_all_subscriptions Error: <%s,%s>\n",attr,child->children->name); 
     669 
     670    goto finish; 
     671 
     672    //lm_message_unref(reply); 
     673    //return NULL;       
     674  } 
     675  else if(lm_message_get_type(reply) == LM_MESSAGE_TYPE_IQ && lm_message_get_sub_type(reply) == LM_MESSAGE_SUB_TYPE_RESULT) { 
     676    child = lm_message_node_find_child(reply->node,"subscriptions"); 
     677    if(child == NULL) { 
     678      g_printerr ("XMPP_Client get_subscriptions: could not find subscriptions in message\n"); 
     679      goto finish; 
     680      //lm_message_unref(reply); 
     681      //return NULL; 
     682    } 
     683     
     684    child = child->children; 
     685    if(child == NULL) { 
     686      g_print("XMPP_Client get_subscriptions: no items in result\n"); 
     687      goto finish; 
     688      //lm_message_unref(reply); 
     689      //return NULL; 
     690    } 
     691 
     692    while(child != NULL) { 
     693      //NodeDesc *tmp = NULL; 
     694      NodeDesc *node = g_new0 (NodeDesc, 1); 
     695      strcpy(node->name,(gchar*) lm_message_node_get_attribute(child,"node")); 
     696      strcpy(node->desc,(gchar*) lm_message_node_get_attribute(child,"subscription")); 
     697      node_list = g_slist_prepend (node_list, node); 
     698      //tmp = (NodeDesc*)node_list->data; 
     699      //g_print("subscription node=%s desc=%s\n",tmp->name, tmp->desc); 
     700      child = child->next; 
     701    } 
     702  } 
     703 
     704finish: 
     705  lm_message_unref(reply); 
    587706  return node_list; 
    588707} 
     
    606725                                     ')', NULL); 
    607726 
     727  lm_message_node_set_attribute(m->node,"from",username); 
     728 
     729#ifdef DEBUG 
     730  g_print("sub message: %s\n",lm_message_node_to_string(m->node)); 
     731#endif 
     732 
    608733  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
     734 
     735#ifdef DEBUG 
     736  g_print("sub reply: %s\n",lm_message_node_to_string(reply->node)); 
     737#endif 
    609738 
    610739  lm_message_unref (m); 
     
    630759    else if(strcmp(attr,"auth")==0) 
    631760      ret = XMPP_ERROR_NOT_AUTHORISED; 
    632      
     761    else 
     762      g_printerr("Subscription Error: <%s,%s>\n",attr,child->children->name); 
     763 
    633764    lm_message_unref(reply); 
    634765    return ret;       
     
    640771} 
    641772 
     773XMPPResult unsubscribe_from_node(gchar *nodeID) 
     774{ 
     775  LmMessage *m, *reply; 
     776  GError *error = NULL; 
     777  
     778  if(connection == NULL) 
     779    return XMPP_ERROR_NOT_INITIALIZED; 
     780  
     781  m = lm_message_build_with_sub_type(_pubsub_server, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_SET, 
     782                                     '(', "pubsub", "", 
     783                                     '@', "xmlns", PUBSUB_NS, 
     784                                     '(', "unsubscribe", "", 
     785                                     '@', "node", nodeID, 
     786                                     '@', "jid", username, 
     787                                     ')', 
     788                                     ')', NULL); 
     789 
     790#ifdef DEBUG 
     791  g_print("unsub message: %s\n",lm_message_node_to_string(m->node)); 
     792#endif 
     793 
     794  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
     795 
     796#ifdef DEBUG 
     797  g_print("unsub reply: %s\n",lm_message_node_to_string(reply->node)); 
     798#endif 
     799 
     800  lm_message_unref (m); 
     801 
     802  if(error != NULL) { 
     803    g_printerr ("XMPP_Client: Failed to send unsubscribe message: error:%d->'%s'\n",error->code,error->message); 
     804    g_free(error); 
     805    lm_message_unref(reply); 
     806    return XMPP_ERROR_UNKNOWN; 
     807  } 
     808 
     809  if(lm_message_get_type(reply) == LM_MESSAGE_TYPE_IQ && lm_message_get_sub_type(reply) == LM_MESSAGE_SUB_TYPE_ERROR) { 
     810    LmMessageNode *child = lm_message_node_find_child(reply->node,"error"); 
     811    const gchar* attr = lm_message_node_get_attribute(child,"type"); 
     812    XMPPResult ret = XMPP_ERROR_UNKNOWN; 
     813     
     814    if(strcmp(attr,"modify")==0) { 
     815      if(strcmp(child->children->name,"subid-required")==0) 
     816        ret = XMPP_ERROR_MULTIPLE_SUBSCRIPTIONS; 
     817      else if(strcmp(child->children->name,"bad-request")==0) 
     818        ret = XMPP_ERROR_MULTIPLE_SUBSCRIPTIONS; 
     819    } 
     820    else if(strcmp(attr,"cancel")==0) { 
     821      if(strcmp(child->children->name,"unexpected-request")==0) 
     822        ret = XMPP_ERROR_NOT_SUBSCRIBED; 
     823      else if(strcmp(child->children->name,"not-subscribed")==0) 
     824        ret = XMPP_ERROR_NOT_SUBSCRIBED;       
     825      else if(strcmp(child->children->name,"item-not-found")==0) 
     826        ret = XMPP_ERROR_NODE_DOESNT_EXIST; 
     827    } 
     828    else if(strcmp(attr,"auth")==0) 
     829      ret = XMPP_ERROR_NOT_AUTHORISED; 
     830    else if(strcmp(attr,"wait")==0) 
     831      ret = XMPP_ERROR_NOT_SUBSCRIBED; 
     832    else { 
     833      g_print("XMPP_Client: Unknown unsubscribe Error: <%s,%s>\n",attr,child->children->name); 
     834    } 
     835    lm_message_unref(reply); 
     836    return ret;       
     837  } 
     838   
     839  lm_message_unref(reply); 
     840   
     841  return XMPP_NO_ERROR;   
     842} 
     843 
     844XMPPResult add_publisher_to_node(gchar *nodeID, gchar *user) 
     845{ 
     846  LmMessage *m, *reply; 
     847  GError *error = NULL; 
     848 
     849  if(connection == NULL) 
     850    return XMPP_ERROR_NOT_INITIALIZED; 
     851   
     852  m = lm_message_build_with_sub_type(_pubsub_server, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_SET,  
     853                                     '(', "pubsub", "", 
     854                                     '@', "xmlns", "http://jabber.org/protocol/pubsub#owner", 
     855                                     '(', "affiliations", "", 
     856                                     '@', "node", nodeID, 
     857                                     '(', "affiliation", "", 
     858                                     '@', "jid", user, 
     859                                     '@', "affiliation", "publisher", 
     860                                     ')', 
     861                                     ')', 
     862                                     ')', NULL); 
     863 
     864#ifdef DEBUG 
     865  g_print("XMPP_Client: add_publisher message: %s\n",lm_message_node_to_string(m->node)); 
     866#endif 
     867 
     868  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
     869 
     870#ifdef DEBUG 
     871  g_print("XMPP_Client: reply to add_publisher message: %s\n",lm_message_node_to_string(reply->node)); 
     872#endif 
     873 
     874  lm_message_unref (m); 
     875 
     876  if(error != NULL) { 
     877    g_printerr ("XMPP_Client: Failed to send add_publisher message: error:%d->'%s'\n",error->code,error->message); 
     878    lm_message_unref(reply); 
     879    g_free(error); 
     880    return XMPP_ERROR_UNKNOWN; 
     881  } 
     882 
     883  if(lm_message_get_type(reply) == LM_MESSAGE_TYPE_IQ && lm_message_get_sub_type(reply) == LM_MESSAGE_SUB_TYPE_ERROR) { 
     884    LmMessageNode *child = lm_message_node_find_child(reply->node,"error"); 
     885    const gchar* attr = lm_message_node_get_attribute(child,"type"); 
     886    XMPPResult ret = XMPP_ERROR_UNKNOWN; 
     887     
     888    if(strcmp(attr,"cancel")==0) { 
     889      if(strcmp(child->children->name,"item-not-found")==0) 
     890        ret = XMPP_ERROR_NODE_DOESNT_EXIST; 
     891      else 
     892        ret = XMPP_ERROR_NOT_SUPPORTED; 
     893    } 
     894    else if(strcmp(attr,"auth")==0) 
     895      ret = XMPP_ERROR_NOT_AUTHORISED; 
     896     
     897    lm_message_unref(reply); 
     898    return ret; 
     899  } 
     900   
     901  lm_message_unref(reply); 
     902   
     903  return XMPP_NO_ERROR; 
     904} 
    642905 
    643906XMPPResult publish_to_node (gchar *nodeID, gchar *event) 
     
    658921                                     ')', 
    659922                                     ')', NULL); 
    660    
     923 
     924#ifdef DEBUG 
     925  g_print("XMPP_Client: publish message: %s\n",lm_message_node_to_string(m->node)); 
     926#endif 
     927 
    661928  reply = lm_connection_send_with_reply_and_block(connection,m,&error); 
     929 
     930#ifdef DEBUG 
     931  g_print("XMPP_Client: reply to publish message: %s\n",lm_message_node_to_string(reply->node)); 
     932#endif 
    662933 
    663934  lm_message_unref (m); 
     
    687958     
    688959    lm_message_unref(reply); 
    689     return ret;       
     960    return ret; 
    690961  } 
    691962   
     
    727998  _pubsub_server = pubsub_server; 
    728999 
     1000#ifdef DEBUG 
     1001  g_print("XMPP_Client: start_xmpp_client\n"); 
     1002#endif 
     1003 
    7291004  connection = lm_connection_new (xmpp_server); 
     1005 
     1006#ifdef DEBUG 
     1007  g_print("XMPP_Client: created new connection\n"); 
     1008#endif 
     1009 
     1010  //Set keep alive rate to 60 seconds 
     1011  lm_connection_set_keep_alive_rate (connection, 60); 
    7301012  lm_connection_set_port (connection, xmpp_server_port); 
    7311013  lm_connection_set_jid (connection, username); 
    732    
     1014 
     1015#ifdef DEBUG 
     1016  g_print("XMPP_Client: set authentication stuff\n"); 
     1017#endif 
     1018 
    7331019  handler = lm_message_handler_new (handle_messages, NULL, NULL); 
    7341020  lm_connection_register_message_handler (connection, handler,  
     
    7381024                                          LM_MESSAGE_TYPE_IQ,  
    7391025                                          LM_HANDLER_PRIORITY_NORMAL); 
    740    
     1026 
    7411027  lm_message_handler_unref (handler); 
    7421028   
     
    7451031                                         NULL, NULL); 
    7461032 
    747   if (_xmpp_ssl_fingerprint) { 
     1033  if (_xmpp_ssl_fingerprint != NULL) { 
     1034#ifdef DEBUG 
     1035    g_print("XMPP_Client: setting SSL fingerprint\n"); 
     1036#endif 
     1037 
    7481038    LmSSL *ssl; 
    7491039    char  *p; 
     
    7661056    lm_ssl_unref (ssl); 
    7671057  } 
    768    
     1058 
     1059#ifdef DEBUG   
     1060  g_print("XMPP_Client: about to open connection\n"); 
     1061#endif 
     1062 
    7691063  result = lm_connection_open (connection, 
    7701064                               (LmResultFunction) connection_open_cb, 
     
    7781072  } 
    7791073 
     1074#ifdef DEBUG 
     1075  g_print("XMPP_Client: creating main loop\n"); 
     1076#endif 
     1077 
    7801078  main_loop = g_main_loop_new (NULL, FALSE); 
     1079  g_main_loop_ref(main_loop); 
    7811080  g_main_loop_run (main_loop); 
     1081  g_main_loop_unref(main_loop); 
     1082 
     1083#ifdef DEBUG 
     1084  g_print("XMPP_Client: finished loop\n"); 
     1085#endif 
    7821086 
    7831087  if(!init_success) 
  • nano-RK/projects/SAMPL/slip-clients/xmpp-client/lm-library.h

    r489 r560  
    22#define __LM_LIBRARY_H__ 
    33 
     4/*! \file lm-library.h 
     5    \brief XMPP Library API 
     6 
     7    This file contains the API to be used by applications 
     8    working with the XMPP framework. 
     9*/ 
     10 
    411#include <string.h> 
    512#include <stdlib.h> 
     
    815#include <loudmouth/loudmouth.h> 
    916 
    10 //#define DEFAULT_FINGERPRINT "52:7A:23:96:2D:74:27:A3:0F:38:3F:AB:AD:14:B7:A2" 
    11  
    12 #define PUBSUB_NS "http://jabber.org/protocol/pubsub" 
    13 #define DEFAULT_RESOURCE "server-test" 
    14  
     17/*! \def NAME_MAX_CHARS 
     18    \brief maximum size of node name 
     19*/ 
     20#define NAME_MAX_CHARS 30 
     21/*! \def DESC_MAX_CHARS 
     22    \brief maximum size of node description 
     23*/ 
     24#define DESC_MAX_CHARS 300 
     25 
     26/*! \enum XMPPResult 
     27    \brief definition of return codes of most API calls 
     28*/ 
    1529typedef enum { 
    1630  XMPP_NO_ERROR = 0, 
     
    2943  XMPP_ERROR_PASSWORD_IS_NULL, 
    3044  XMPP_ERROR_ARGUMENT_IS_NULL, 
     45  XMPP_ERROR_MULTIPLE_SUBSCRIPTIONS, 
     46  XMPP_ERROR_NOT_SUBSCRIBED, 
    3147  XMPP_ERROR_UNKNOWN 
    3248} XMPPResult; 
    3349 
     50/*! \struct XMPPErrorMessage 
     51    \brief Definiton of Error Struct 
     52 
     53   Used to map error codes to error messages 
     54*/ 
    3455static struct XMPPErrorMessage { 
    3556  XMPPResult error_code; 
     
    4162  { XMPP_ERROR_NOT_REGISTERED,                     "Need to be registered with service to perform specified action" }, 
    4263  { XMPP_ERROR_NODE_EXISTS,                        "Node ID exists" }, 
    43   { XMPP_ERROR_NOT_ALLOWED,                        "Requestion Action not allowed" }, 
     64  { XMPP_ERROR_NOT_ALLOWED,                        "Requested Action not allowed" }, 
    4465  { XMPP_ERROR_MULTIPLE_PARENTS_NOT_ALLOWED,       "PubSub Service does not support multiple node parents" }, 
    4566  { XMPP_ERROR_NOT_COLLECTION_NODE,                "Specified node is not a collection node" }, 
     
    5172  { XMPP_ERROR_PASSWORD_IS_NULL,                   "Password is NULL" }, 
    5273  { XMPP_ERROR_ARGUMENT_IS_NULL,                   "Argument is NULL" }, 
     74  { XMPP_ERROR_MULTIPLE_SUBSCRIPTIONS,             "Multiple subscriptions exist from jid to node" }, 
     75  { XMPP_ERROR_NOT_SUBSCRIBED,                     "Not subscribed to node" }, 
    5376  { XMPP_ERROR_UNKNOWN,                            "Unknown Error" } 
    5477}; 
    5578 
     79/*! \def ERROR_MESSAGE(a) 
     80    \brief a macro that returns error description of an error code 
     81*/ 
    5682#define ERROR_MESSAGE(a) error_desc[a].error_message 
    5783 
    5884G_BEGIN_DECLS 
    5985 
     86/*! \var tpedef void (* XMPPMessageHandler) (LmMessage *message) 
     87    \brief type definition for a XMPP message handler 
     88*/ 
    6089typedef void (* XMPPMessageHandler) (LmMessage *message); 
    6190 
    6291G_END_DECLS 
    6392 
     93/*! \struct NodeDesc 
     94    \brief struct for node details 
     95 
     96    NodeDesc is used to describe nodes. It is used in lists of event nodes. 
     97*/ 
    6498typedef struct { 
    65   gchar* name; 
    66   gchar* desc; 
     99  /*! name of event node */ 
     100  gchar name[NAME_MAX_CHARS]; 
     101  /*! description of event node */ 
     102  gchar desc[DESC_MAX_CHARS];  
    67103} NodeDesc; 
    68104 
     105/*! \fn XMPPResult create_event_node(gchar *nodeID,  
     106                                     GSList* collectionList,  
     107                                     gboolean isCollection); 
     108    \brief Create an event node 
     109    \param nodeID ID of event node to create 
     110    \param collectionList List of IDs of nodes of which this node will be a child 
     111    \param isCollection specify if this node is a collection or a leaf 
     112    \return Result Code 
     113*/ 
    69114XMPPResult create_event_node(gchar *nodeID,  
    70                              GSList* collectionNodeID,  
     115                             GSList* collectionList,  
    71116                             gboolean isCollection); 
    72117 
     118/*! \fn XMPPResult create_event_node_with_desc(gchar *nodeID, 
     119                                               gchar *desc, 
     120                                               GSList* collectionList,  
     121                                               gboolean isCollection); 
     122    \brief Create an event node with a specified description 
     123    \param nodeID ID of event node to create 
     124    \param desc Description of event node 
     125    \param collectionList List of IDs of event nodes of which this event node will be a child 
     126    \param isCollection specify if this event node is a collection or a leaf 
     127    \return Result Code 
     128*/ 
     129XMPPResult create_event_node_with_desc(gchar *nodeID,  
     130                                       gchar *desc, 
     131                                       GSList* collectionList,  
     132                                       gboolean isCollection); 
     133 
     134/*! \fn XMPPResult delete_event_node(gchar *nodeID) 
     135    \brief Delete an event node 
     136    \param nodeID ID of event node to delete 
     137    \return Result Code 
     138*/ 
    73139XMPPResult delete_event_node(gchar *nodeID); 
    74140 
     141/*! \fn XMPPResult add_node_to_collection(gchar* nodeID,  
     142                                          gchar* collectionID) 
     143    \brief Add event node to a collection node 
     144    \param nodeID ID of event node 
     145    \param collectionID ID of event node to attach as parent 
     146    \return Result code 
     147*/ 
    75148XMPPResult add_node_to_collection(gchar* nodeID,  
    76                                   gchar* collectionNodeID); 
    77  
     149                                  gchar* collectionID); 
     150 
     151/*! \fn XMPPResult remove_node_from_collection(gchar* nodeID,  
     152                                               gchar* collectionID) 
     153    \brief Remove event node from a collection node 
     154    \param nodeID ID of event node 
     155    \param collectionID ID of event node to remove as parent 
     156    \return Result code 
     157*/ 
    78158XMPPResult remove_node_from_collection(gchar *nodeID,  
    79                                        gchar* collectionNodeID); 
    80  
     159                                       gchar* collectionID); 
     160 
     161/*! \fn GSList* get_node_list(void) 
     162    \brief Get list of event nodes on server 
     163    \return List of event nodes on server. NULL if no nodes exist. 
     164*/ 
    81165GSList* get_node_list(void); 
    82166 
     167/*! \fn XMPPResult subscribe_to_node(gchar *nodeID) 
     168    \brief Subscribe to event node 
     169    \param nodeID ID of event node to subscribe to 
     170    \return Result code 
     171*/ 
    83172XMPPResult subscribe_to_node(gchar *nodeID); 
    84173 
     174/*! \fn XMPPResult unsubscribe_from_node(gchar *nodeID) 
     175    \brief Unsubscribe from event node 
     176    \param nodeID ID of event node to unsubscribe from 
     177    \return Result Code 
     178*/ 
    85179XMPPResult unsubscribe_from_node(gchar *nodeID); 
    86180 
     181/*! \fn XMPPResult publish_to_node(gchar *nodeID, gchar* event) 
     182    \brief Publish data to node 
     183    \param nodeID ID of event node to publish to 
     184    \param event Data to send to node 
     185    \return Result Code 
     186*/                                
    87187XMPPResult publish_to_node(gchar *nodeID,  
    88188                           gchar *event); 
    89189 
     190/*! \fn GSList* get_all_current_subscriptions(void) 
     191    \brief Get all event node subscriptions of current user 
     192    \return List of event nodes to which user is subscribed. NULL if no such nodes exist. 
     193*/ 
     194GSList* get_all_current_subscriptions(void); 
     195 
     196/*! \fn XMPPResult add_publisher_to_node(gchar* nodeID, gchar* user) 
     197    \brief Add a JID as an allowed publisher to an event node 
     198    \param nodeID event node ID to add publisher to 
     199    \param user Full JID of user to add as publisher 
     200    \return Result code 
     201*/ 
     202XMPPResult add_publisher_to_node(gchar *nodeID, gchar *user);  
     203 
     204/*! \fn start_xmpp_client(const gchar *user_name,  
     205                             const gchar *pass_word,  
     206                             const gchar *xmpp_server,  
     207                             const int xmpp_server_port,  
     208                             const gchar *xmpp_server_fingerprint,  
     209                             const gchar *pubsub_server,  
     210                             XMPPMessageHandler user_handler) 
     211    \brief Start XMPP Client 
     212    \param user_name JID of user. format is user\@domain 
     213    \param pass_word password associated with JID 
     214    \param xmpp_server name of XMPP server. Usually domain of JID. 
     215    \param xmpp_server_port Port of server to connect to. Normally 5223 
     216    \param xmpp_server_fingerprint SSL Fingerprint of XMPP server 
     217    \param pubsub_server PubSub Service address. Usually pubsub.domain 
     218    \param user_handler Message handler to call when XMPP messages are received 
     219    \return Result Code 
     220*/ 
    90221XMPPResult start_xmpp_client(const gchar *user_name,  
    91222                             const gchar *pass_word,  
     
    96227                             XMPPMessageHandler user_handler); 
    97228 
     229 
    98230#endif 
  • nano-RK/src/kernel/source/nrk_error.c

    r540 r560  
    7979    return 0; 
    8080  
    81 #ifndef NRK_REBOOT_ON_ERROR 
    8281   #ifdef NRK_HALT_ON_ERROR 
    83    nrk_int_disable (); 
    84    #ifdef NRK_WATCHDOG 
    85    nrk_watchdog_disable(); 
    86    #endif 
     82     nrk_int_disable (); 
     83     #ifndef NRK_REBOOT_ON_ERROR 
     84       #ifdef NRK_WATCHDOG 
     85         nrk_watchdog_disable(); 
     86       #endif 
     87     #endif  
    8788   #endif  
    88 #endif  
     89 
    8990 
    9091#ifdef NRK_HALT_AND_LOOP_ON_ERROR  
     
    9798     { 
    9899     
    99 #endif  /*  */ 
    100 /* 
    101         for(t=0; t<80; t++ ) 
    102         { 
    103         printf( "stk %d:%x\r\n",-t+40,nrk_task_TCB[error_task].OSTaskStkPtr[-t+40] ); 
    104  
    105         } 
    106 */ 
    107       nrk_kprintf (PSTR ("*NRK ERROR(")); 
     100#endif   
     101     
     102    nrk_kprintf (PSTR ("*NRK ERROR(")); 
    108103    printf ("%d", error_task); 
    109104    nrk_kprintf (PSTR ("): ")); 
     
    174169#ifdef NRK_REBOOT_ON_ERROR 
    175170  // wait for watchdog to kick in 
    176   nrk_int_enable();  
     171  nrk_watchdog_disable(); 
     172  nrk_int_disable();  
    177173  while(1); 
    178174#endif