1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940
|
/*
* nmevent.c
*
* Copyright (c) 2004 Novell, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; version 2 of the License.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#include <glib.h>
#include <string.h>
#include <time.h>
#include "nmevent.h"
#include "nmfield.h"
#include "nmconn.h"
#include "nmuserrecord.h"
#include "nmrtf.h"
#define MAX_UINT32 0xFFFFFFFF
struct _NMEvent
{
/* Event type */
int type;
/* The DN of the event source */
char *source;
/* Timestamp of the event */
guint32 gmt;
/* Conference to associate with the event */
NMConference *conference;
/* User record to associate with the event */
NMUserRecord *user_record;
/* Text associated with the event */
char *text;
/* Reference count for event structure */
int ref_count;
};
/* Handle getdetails response and set the new user record into the event */
static void
_got_user_for_event(NMUser * user, NMERR_T ret_val,
gpointer resp_data, gpointer user_data)
{
NMUserRecord *user_record;
NMEvent *event;
nm_event_cb cb;
if (user == NULL)
return;
user_record = resp_data;
event = user_data;
if (ret_val == NM_OK) {
if (event && user_record) {
/* Add the user record to the event structure
* and make the callback.
*/
nm_event_set_user_record(event, user_record);
if ((cb = nm_user_get_event_callback(user))) {
cb(user, event);
}
}
} else {
/* Cleanup resp_data */
}
/* Clean up */
if (event)
nm_release_event(event);
}
/* Handle getdetails response, set the new user record into the event
* and add the user record as a participant in the conference
*/
static void
_got_user_for_conference(NMUser * user, NMERR_T ret_val,
gpointer resp_data, gpointer user_data)
{
NMUserRecord *user_record = resp_data;
NMEvent *event = user_data;
NMConference *conference;
nm_event_cb cb;
if (user == NULL)
return;
if (event && user_record) {
conference = nm_event_get_conference(event);
if (conference) {
/* Add source of event as recip of the conference */
nm_conference_add_participant(conference, user_record);
/* Add the user record to the event structure
* and make the callback.
*/
nm_event_set_user_record(event, user_record);
if ((cb = nm_user_get_event_callback(user))) {
cb(user, event);
}
}
}
if (event)
nm_release_event(event);
}
/* Read the receive message event, set up the event object, and
* get details for the event source if we don't have them yet.
*/
static NMERR_T
handle_receive_message(NMUser * user, NMEvent * event, gboolean autoreply)
{
NMConference *conference;
NMUserRecord *user_record;
NMConn *conn;
NMERR_T rc = NM_OK;
guint32 size = 0, flags = 0;
char *msg = NULL;
char *nortf = NULL;
char *guid = NULL;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
/* Read the conference flags */
if (rc == NM_OK) {
rc = nm_read_uint32(conn, &flags);
}
/* Read the message text */
if (rc == NM_OK) {
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
msg = g_new0(char, size + 1);
rc = nm_read_all(conn, msg, size);
purple_debug(PURPLE_DEBUG_INFO, "novell", "Message is %s\n", msg);
/* Auto replies are not in RTF format! */
if (!autoreply) {
NMRtfContext *ctx;
ctx = nm_rtf_init();
nortf = nm_rtf_strip_formatting(ctx, msg);
nm_rtf_deinit(ctx);
purple_debug(PURPLE_DEBUG_INFO, "novell",
"Message without RTF is %s\n", nortf);
/* Store the event data */
nm_event_set_text(event, nortf);
} else {
/* Store the event data */
nm_event_set_text(event, msg);
}
}
}
/* Check to see if we already know about the conference */
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_conference_set_flags(conference, flags);
nm_event_set_conference(event, conference);
/* Add a reference to the user record in our event object */
user_record = nm_find_user_record(user, nm_event_get_source(event));
if (user_record) {
nm_event_set_user_record(event, user_record);
}
} else {
/* This is a new conference, so create one and add it to our list */
conference = nm_create_conference(guid);
nm_conference_set_flags(conference, flags);
/* Add a reference to the conference in the event */
nm_event_set_conference(event, conference);
/* Add new conference to the conference list */
nm_conference_list_add(user, conference);
/* Check to see if we have details for the event source yet */
user_record = nm_find_user_record(user, nm_event_get_source(event));
if (user_record) {
/* We do so add the user record as a recipient of the conference */
nm_conference_add_participant(conference, user_record);
/* Add a reference to the user record in our event object */
nm_event_set_user_record(event, user_record);
} else {
/* Need to go to the server to get details for the user */
rc = nm_send_get_details(user, nm_event_get_source(event),
_got_user_for_conference, event);
if (rc == NM_OK)
rc = -1; /* Not done processing the event yet! */
}
nm_release_conference(conference);
}
if (msg)
g_free(msg);
if (nortf)
g_free(nortf);
if (guid)
g_free(guid);
return rc;
}
/* Read the invite event, set up the event object, and
* get details for the event source if we don't have them yet.
*/
static NMERR_T
handle_conference_invite(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
char *guid = NULL;
char *msg = NULL;
NMConn *conn;
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
/* Read the the message */
if (rc == NM_OK) {
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
msg = g_new0(char, size + 1);
rc = nm_read_all(conn, msg, size);
}
}
/* Store the event data */
if (rc == NM_OK) {
NMConference *conference;
nm_event_set_text(event, msg);
conference = nm_conference_list_find(user, guid);
if (conference == NULL) {
conference = nm_create_conference(guid);
/* Add new conference to the list and the event */
nm_conference_list_add(user, conference);
nm_event_set_conference(event, conference);
/* Check to see if we have details for the event source yet */
user_record = nm_find_user_record(user, nm_event_get_source(event));
if (user_record) {
/* Add a reference to the user record in our event object */
nm_event_set_user_record(event, user_record);
} else {
/* Need to go to the server to get details for the user */
rc = nm_send_get_details(user, nm_event_get_source(event),
_got_user_for_event, event);
if (rc == NM_OK)
rc = -1; /* Not done processing the event yet! */
}
nm_release_conference(conference);
}
}
if (msg)
g_free(msg);
if (guid)
g_free(guid);
return rc;
}
/* Read the invite notify event, set up the event object, and
* get details for the event source if we don't have them yet.
*/
static NMERR_T
handle_conference_invite_notify(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
char *guid = NULL;
NMConn *conn;
NMConference *conference;
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_event_set_conference(event, conference);
/* Check to see if we have details for the event source yet */
user_record = nm_find_user_record(user, nm_event_get_source(event));
if (user_record) {
/* Add a reference to the user record in our event object */
nm_event_set_user_record(event, user_record);
} else {
/* Need to go to the server to get details for the user */
rc = nm_send_get_details(user, nm_event_get_source(event),
_got_user_for_event, event);
if (rc == NM_OK)
rc = -1; /* Not done processing the event yet! */
}
} else {
rc = NMERR_CONFERENCE_NOT_FOUND;
}
if (guid)
g_free(guid);
return rc;
}
/* Read the conference reject event and set up the event object */
static NMERR_T
handle_conference_reject(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
char *guid = NULL;
NMConn *conn;
NMConference *conference;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
if (rc == NM_OK) {
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_event_set_conference(event, conference);
} else {
rc = NMERR_CONFERENCE_NOT_FOUND;
}
}
if (guid)
g_free(guid);
return rc;
}
/* Read the conference left event, set up the event object, and
* remove the conference from the list if there are no more
* participants
*/
static NMERR_T
handle_conference_left(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0, flags = 0;
char *guid = NULL;
NMConference *conference;
NMConn *conn;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
/* Read the conference flags */
if (rc == NM_OK) {
rc = nm_read_uint32(conn, &flags);
}
if (rc == NM_OK) {
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_event_set_conference(event, conference);
nm_conference_set_flags(conference, flags);
nm_conference_remove_participant(conference, nm_event_get_source(event));
if (nm_conference_get_participant_count(conference) == 0) {
nm_conference_list_remove(user, conference);
}
} else {
rc = NMERR_CONFERENCE_NOT_FOUND;
}
}
if (guid)
g_free(guid);
return rc;
}
/* Read the conference closed, set up the event object, and
* remove the conference from the list
*/
static NMERR_T
handle_conference_closed(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
char *guid = NULL;
NMConference *conference;
NMConn *conn;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
if (rc == NM_OK) {
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_event_set_conference(event, conference);
nm_conference_list_remove(user, conference);
} else {
rc = NMERR_CONFERENCE_NOT_FOUND;
}
}
if (guid)
g_free(guid);
return rc;
}
/* Read the conference joined event, set up the event object, and
* get details for the event source if we don't have them yet.
*/
static NMERR_T
handle_conference_joined(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0, flags = 0;
char *guid = NULL;
NMConn *conn;
NMConference *conference;
NMUserRecord *user_record;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
/* Read the conference flags */
if (rc == NM_OK) {
rc = nm_read_uint32(conn, &flags);
}
if (rc == NM_OK) {
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_conference_set_flags(conference, flags);
nm_event_set_conference(event, conference);
/* Add the new user to the participants list */
user_record = nm_find_user_record(user, nm_event_get_source(event));
if (user_record) {
nm_conference_remove_participant(conference,
nm_user_record_get_dn(user_record));
nm_conference_add_participant(conference, user_record);
} else {
/* Need to go to the server to get details for the user */
rc = nm_send_get_details(user, nm_event_get_source(event),
_got_user_for_conference, event);
if (rc == NM_OK)
rc = -1; /* Not done processing the event yet! */
}
} else {
rc = NMERR_CONFERENCE_NOT_FOUND;
}
}
if (guid)
g_free(guid);
return rc;
}
/* Read the typing event and set up the event object */
static NMERR_T
handle_typing(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
char *guid = NULL;
NMConference *conference;
NMConn *conn;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
if (rc == NM_OK) {
conference = nm_conference_list_find(user, guid);
if (conference) {
nm_event_set_conference(event, conference);
} else {
rc = NMERR_CONFERENCE_NOT_FOUND;
}
}
if (guid)
g_free(guid);
return rc;
}
/* Read the event, set up the event object, and update
* the status in the user record (for the event source)
*/
static NMERR_T
handle_status_change(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint16 status;
guint32 size;
char *text = NULL;
NMUserRecord *user_record;
NMConn *conn;
conn = nm_user_get_conn(user);
/* Read new status */
rc = nm_read_uint16(conn, &status);
if (rc == NM_OK) {
/* Read the status text */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
text = g_new0(char, size + 1);
rc = nm_read_all(conn, text, size);
}
}
if (rc == NM_OK) {
nm_event_set_text(event, text);
/* Get a reference to the user record and store the new status */
user_record = nm_find_user_record(user, nm_event_get_source(event));
if (user_record) {
nm_event_set_user_record(event, user_record);
nm_user_record_set_status(user_record, status, text);
}
}
if (text)
g_free(text);
return rc;
}
/* Read the undeliverable event */
static NMERR_T
handle_undeliverable_status(NMUser * user, NMEvent * event)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
char *guid = NULL;
NMConn *conn;
conn = nm_user_get_conn(user);
/* Read the conference guid */
rc = nm_read_uint32(conn, &size);
if (size == MAX_UINT32) return NMERR_PROTOCOL;
if (rc == NM_OK) {
guid = g_new0(char, size + 1);
rc = nm_read_all(conn, guid, size);
}
if (guid)
g_free(guid);
return rc;
}
/*******************************************************************************
* Event API -- see header file for comments
******************************************************************************/
NMEvent *
nm_create_event(int type, const char *source, guint32 gmt)
{
NMEvent *event = g_new0(NMEvent, 1);
event->type = type;
event->gmt = gmt;
if (source)
event->source = g_strdup(source);
event->ref_count = 1;
return event;
}
void
nm_release_event(NMEvent * event)
{
if (event == NULL) {
return;
}
if (--(event->ref_count) == 0) {
if (event->source)
g_free(event->source);
if (event->conference)
nm_release_conference(event->conference);
if (event->user_record)
nm_release_user_record(event->user_record);
if (event->text)
g_free(event->text);
g_free(event);
}
}
NMConference *
nm_event_get_conference(NMEvent * event)
{
if (event)
return event->conference;
else
return NULL;
}
void
nm_event_set_conference(NMEvent * event, NMConference * conference)
{
if (event && conference) {
nm_conference_add_ref(conference);
event->conference = conference;
}
}
NMUserRecord *
nm_event_get_user_record(NMEvent * event)
{
if (event)
return event->user_record;
else
return NULL;
}
void
nm_event_set_user_record(NMEvent * event, NMUserRecord * user_record)
{
if (event && user_record) {
nm_user_record_add_ref(user_record);
event->user_record = user_record;
}
}
const char *
nm_event_get_text(NMEvent * event)
{
if (event)
return event->text;
else
return NULL;
}
void
nm_event_set_text(NMEvent * event, const char *text)
{
if (event) {
if (text)
event->text = g_strdup(text);
else
event->text = NULL;
}
}
const char *
nm_event_get_source(NMEvent * event)
{
if (event)
return event->source;
else
return NULL;
}
int
nm_event_get_type(NMEvent * event)
{
if (event)
return event->type;
else
return -1;
}
time_t
nm_event_get_gmt(NMEvent * event)
{
if (event)
return event->gmt;
else
return (time_t)-1;
}
NMERR_T
nm_process_event(NMUser * user, int type)
{
NMERR_T rc = NM_OK;
guint32 size = 0;
NMEvent *event = NULL;
char *source = NULL;
nm_event_cb cb;
NMConn *conn;
if (user == NULL)
return NMERR_BAD_PARM;
if (type < NMEVT_START || type > NMEVT_STOP)
return NMERR_PROTOCOL;
conn = nm_user_get_conn(user);
/* Read the event source */
rc = nm_read_uint32(conn, &size);
if (rc == NM_OK) {
if (size > 0) {
source = g_new0(char, size);
rc = nm_read_all(conn, source, size);
}
}
/* Read the event data */
if (rc == NM_OK) {
event = nm_create_event(type, source, time(0));
if (event) {
switch (type) {
case NMEVT_STATUS_CHANGE:
rc = handle_status_change(user, event);
break;
case NMEVT_RECEIVE_MESSAGE:
rc = handle_receive_message(user, event, FALSE);
break;
case NMEVT_RECEIVE_AUTOREPLY:
rc = handle_receive_message(user, event, TRUE);
break;
case NMEVT_USER_TYPING:
case NMEVT_USER_NOT_TYPING:
rc = handle_typing(user, event);
break;
case NMEVT_CONFERENCE_LEFT:
rc = handle_conference_left(user, event);
break;
case NMEVT_CONFERENCE_CLOSED:
rc = handle_conference_closed(user, event);
break;
case NMEVT_CONFERENCE_JOINED:
rc = handle_conference_joined(user, event);
break;
case NMEVT_CONFERENCE_INVITE:
rc = handle_conference_invite(user, event);
break;
case NMEVT_CONFERENCE_REJECT:
rc = handle_conference_reject(user, event);
break;
case NMEVT_CONFERENCE_INVITE_NOTIFY:
rc = handle_conference_invite_notify(user, event);
break;
case NMEVT_UNDELIVERABLE_STATUS:
rc = handle_undeliverable_status(user, event);
break;
case NMEVT_INVALID_RECIPIENT:
/* Nothing else to read, just callback */
break;
case NMEVT_USER_DISCONNECT:
/* Nothing else to read, just callback */
break;
case NMEVT_SERVER_DISCONNECT:
/* Nothing else to read, just callback */
break;
case NMEVT_RECEIVE_FILE:
case NMEVT_CONTACT_ADD:
/* Safely ignored for now */
break;
default:
purple_debug(PURPLE_DEBUG_INFO, "novell",
"Unknown event %d received.\n", type);
rc = NMERR_PROTOCOL;
break;
}
}
}
if (rc == (NMERR_T)-1) {
/* -1 means that we are not ready to callback yet. */
rc = NM_OK;
} else if (rc == NM_OK && (cb = nm_user_get_event_callback(user))) {
cb(user, event);
if (event)
nm_release_event(event);
} else {
if (event)
nm_release_event(event);
}
/* Cleanup */
if (source)
g_free(source);
return rc;
}
|