Changeset 560
- Timestamp:
- 04/30/08 01:07:04 (2 weeks ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nano-RK/projects/SAMPL/slip-clients/xmpp-client/lm-library.c
r489 r560 1 1 #include "lm-library.h" 2 2 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" 4 7 5 8 static GMainLoop *main_loop = NULL; … … 177 180 gpointer ud) 178 181 { 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 181 187 switch (status) { 182 188 case LM_SSL_STATUS_NO_CERT_FOUND: … … 204 210 break; 205 211 } 206 212 #endif 213 207 214 return LM_SSL_RESPONSE_CONTINUE; 208 215 } … … 215 222 if (success) { 216 223 LmMessage *m; 217 224 225 #ifdef DEBUG 218 226 g_print ("XMPP_Client: Authenticated successfully\n"); 227 #endif 219 228 220 229 init_success = TRUE; … … 224 233 LM_MESSAGE_SUB_TYPE_AVAILABLE); 225 234 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 228 240 lm_message_unref (m); 229 241 … … 250 262 NULL, FALSE, NULL); 251 263 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 254 269 } else { 255 270 g_printerr ("XMPP_Client: Failed to connect\n"); … … 293 308 gpointer user_data) 294 309 { 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)); 301 313 302 314 if( (lm_message_get_type(m) == LM_MESSAGE_TYPE_MESSAGE) && … … 307 319 } 308 320 309 310 321 XMPPResult create_event_node (gchar *nodeID, 311 322 GSList *collectionList, 312 323 gboolean isCollection) 324 { 325 return create_event_node_with_desc (nodeID,"default",collectionList,isCollection); 326 } 327 328 329 XMPPResult create_event_node_with_desc (gchar *nodeID, 330 gchar *desc, 331 GSList *collectionList, 332 gboolean isCollection) 313 333 { 314 334 LmMessage *m,*reply; … … 344 364 ')', 345 365 ')', 366 '(', "field", "", 367 '@', "var", "pubsub#title", 368 '(', "value", desc, 369 ')', 370 ')', 346 371 ')', 347 372 ')', … … 481 506 482 507 reply = lm_connection_send_with_reply_and_block(connection,m,&error); 483 508 484 509 lm_message_unref(m); 485 510 … … 543 568 '@', "xmlns", "http://jabber.org/protocol/disco#items", 544 569 ')', 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 546 575 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 547 580 548 581 lm_message_unref (m); … … 559 592 child = lm_message_node_find_child(reply->node,"query"); 560 593 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"); 562 595 lm_message_unref(reply); 563 596 return NULL; … … 566 599 child = child->children; 567 600 if(child == NULL) { 568 g_print(" no items in query result\n");601 g_print("XMPP_Client: no items in query result\n"); 569 602 lm_message_unref(reply); 570 603 return NULL; … … 573 606 while(child != NULL) { 574 607 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")); 577 610 node_list = g_slist_prepend (node_list, node); 578 611 child = child->next; … … 580 613 } 581 614 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")); 583 616 lm_message_unref(reply); 584 617 return NULL; 585 618 } 586 619 620 lm_message_unref(reply); 621 return node_list; 622 } 623 624 GSList* 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 704 finish: 705 lm_message_unref(reply); 587 706 return node_list; 588 707 } … … 606 725 ')', NULL); 607 726 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 608 733 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 609 738 610 739 lm_message_unref (m); … … 630 759 else if(strcmp(attr,"auth")==0) 631 760 ret = XMPP_ERROR_NOT_AUTHORISED; 632 761 else 762 g_printerr("Subscription Error: <%s,%s>\n",attr,child->children->name); 763 633 764 lm_message_unref(reply); 634 765 return ret; … … 640 771 } 641 772 773 XMPPResult 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 844 XMPPResult 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 } 642 905 643 906 XMPPResult publish_to_node (gchar *nodeID, gchar *event) … … 658 921 ')', 659 922 ')', 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 661 928 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 662 933 663 934 lm_message_unref (m); … … 687 958 688 959 lm_message_unref(reply); 689 return ret; 960 return ret; 690 961 } 691 962 … … 727 998 _pubsub_server = pubsub_server; 728 999 1000 #ifdef DEBUG 1001 g_print("XMPP_Client: start_xmpp_client\n"); 1002 #endif 1003 729 1004 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); 730 1012 lm_connection_set_port (connection, xmpp_server_port); 731 1013 lm_connection_set_jid (connection, username); 732 1014 1015 #ifdef DEBUG 1016 g_print("XMPP_Client: set authentication stuff\n"); 1017 #endif 1018 733 1019 handler = lm_message_handler_new (handle_messages, NULL, NULL); 734 1020 lm_connection_register_message_handler (connection, handler, … … 738 1024 LM_MESSAGE_TYPE_IQ, 739 1025 LM_HANDLER_PRIORITY_NORMAL); 740 1026 741 1027 lm_message_handler_unref (handler); 742 1028 … … 745 1031 NULL, NULL); 746 1032 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 748 1038 LmSSL *ssl; 749 1039 char *p; … … 766 1056 lm_ssl_unref (ssl); 767 1057 } 768 1058 1059 #ifdef DEBUG 1060 g_print("XMPP_Client: about to open connection\n"); 1061 #endif 1062 769 1063 result = lm_connection_open (connection, 770 1064 (LmResultFunction) connection_open_cb, … … 778 1072 } 779 1073 1074 #ifdef DEBUG 1075 g_print("XMPP_Client: creating main loop\n"); 1076 #endif 1077 780 1078 main_loop = g_main_loop_new (NULL, FALSE); 1079 g_main_loop_ref(main_loop); 781 1080 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 782 1086 783 1087 if(!init_success) nano-RK/projects/SAMPL/slip-clients/xmpp-client/lm-library.h
r489 r560 2 2 #define __LM_LIBRARY_H__ 3 3 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 4 11 #include <string.h> 5 12 #include <stdlib.h> … … 8 15 #include <loudmouth/loudmouth.h> 9 16 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 */ 15 29 typedef enum { 16 30 XMPP_NO_ERROR = 0, … … 29 43 XMPP_ERROR_PASSWORD_IS_NULL, 30 44 XMPP_ERROR_ARGUMENT_IS_NULL, 45 XMPP_ERROR_MULTIPLE_SUBSCRIPTIONS, 46 XMPP_ERROR_NOT_SUBSCRIBED, 31 47 XMPP_ERROR_UNKNOWN 32 48 } XMPPResult; 33 49 50 /*! \struct XMPPErrorMessage 51 \brief Definiton of Error Struct 52 53 Used to map error codes to error messages 54 */ 34 55 static struct XMPPErrorMessage { 35 56 XMPPResult error_code; … … 41 62 { XMPP_ERROR_NOT_REGISTERED, "Need to be registered with service to perform specified action" }, 42 63 { XMPP_ERROR_NODE_EXISTS, "Node ID exists" }, 43 { XMPP_ERROR_NOT_ALLOWED, "Request ionAction not allowed" },64 { XMPP_ERROR_NOT_ALLOWED, "Requested Action not allowed" }, 44 65 { XMPP_ERROR_MULTIPLE_PARENTS_NOT_ALLOWED, "PubSub Service does not support multiple node parents" }, 45 66 { XMPP_ERROR_NOT_COLLECTION_NODE, "Specified node is not a collection node" }, … … 51 72 { XMPP_ERROR_PASSWORD_IS_NULL, "Password is NULL" }, 52 73 { 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" }, 53 76 { XMPP_ERROR_UNKNOWN, "Unknown Error" } 54 77 }; 55 78 79 /*! \def ERROR_MESSAGE(a) 80 \brief a macro that returns error description of an error code 81 */ 56 82 #define ERROR_MESSAGE(a) error_desc[a].error_message 57 83 58 84 G_BEGIN_DECLS 59 85 86 /*! \var tpedef void (* XMPPMessageHandler) (LmMessage *message) 87 \brief type definition for a XMPP message handler 88 */ 60 89 typedef void (* XMPPMessageHandler) (LmMessage *message); 61 90 62 91 G_END_DECLS 63 92 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 */ 64 98 typedef 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]; 67 103 } NodeDesc; 68 104 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 */ 69 114 XMPPResult create_event_node(gchar *nodeID, 70 GSList* collection NodeID,115 GSList* collectionList, 71 116 gboolean isCollection); 72 117 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 */ 129 XMPPResult 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 */ 73 139 XMPPResult delete_event_node(gchar *nodeID); 74 140 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 */ 75 148 XMPPResult 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 */ 78 158 XMPPResult 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 */ 81 165 GSList* get_node_list(void); 82 166 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 */ 83 172 XMPPResult subscribe_to_node(gchar *nodeID); 84 173 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 */ 85 179 XMPPResult unsubscribe_from_node(gchar *nodeID); 86 180 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 */ 87 187 XMPPResult publish_to_node(gchar *nodeID, 88 188 gchar *event); 89 189 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 */ 194 GSList* 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 */ 202 XMPPResult 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 */ 90 221 XMPPResult start_xmpp_client(const gchar *user_name, 91 222 const gchar *pass_word, … … 96 227 XMPPMessageHandler user_handler); 97 228 229 98 230 #endif nano-RK/src/kernel/source/nrk_error.c
r540 r560 79 79 return 0; 80 80 81 #ifndef NRK_REBOOT_ON_ERROR82 81 #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 87 88 #endif 88 #endif 89 89 90 90 91 #ifdef NRK_HALT_AND_LOOP_ON_ERROR … … 97 98 { 98 99 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(")); 108 103 printf ("%d", error_task); 109 104 nrk_kprintf (PSTR ("): ")); … … 174 169 #ifdef NRK_REBOOT_ON_ERROR 175 170 // wait for watchdog to kick in 176 nrk_int_enable(); 171 nrk_watchdog_disable(); 172 nrk_int_disable(); 177 173 while(1); 178 174 #endif
