コード例 #1
0
ファイル: sipe-xml-tests.c プロジェクト: rravinuthala/sipe
static void assert_stringify(const sipe_xml *xml,
			     int expected, ...)
{
	va_list args;
	gchar *string = sipe_xml_stringify(xml);

	va_start(args, expected);
	while (expected-- > 0) {
		const gchar *alternative = va_arg(args, const gchar *);
		if (sipe_strequal(string, alternative)) {
			succeeded++;
			break;
		} else {
			printf("XML stringify alternative FAILED: '%s' (trying next...)\n",
			       alternative ? alternative : "(nil)");
		}
	}
	va_end(args);

	if (expected < 0) {
		printf("[%s]\nXML stringify all alternatives FAILED: '%s'\n",
		       teststring, string ? string : "(nil)");
		failed++;
	}

	g_free(string);
}
コード例 #2
0
void sipe_ocs2005_user_info_has_updated(struct sipe_core_private *sipe_private,
                                        const sipe_xml *xn_userinfo)
{
    const sipe_xml *xn_states;

    g_free(sipe_private->ocs2005_user_states);
    sipe_private->ocs2005_user_states = NULL;
    if ((xn_states = sipe_xml_child(xn_userinfo, "states")) != NULL) {
        gchar *orig = sipe_private->ocs2005_user_states = sipe_xml_stringify(xn_states);

        /* this is a hack-around to remove added newline after inner element,
         * state in this case, where it shouldn't be.
         * After several use of sipe_xml_stringify, amount of added newlines
         * grows significantly.
         */
        if (orig) {
            gchar c, *stripped = orig;
            while ((c = *orig++)) {
                if ((c != '\n') /* && (c != '\r') */) {
                    *stripped++ = c;
                }
            }
            *stripped = '\0';
        }
    }

    /* Publish initial state if not yet.
     * Assuming this happens on initial responce to self subscription
     * so we've already updated our UserInfo.
     */
    if (!SIPE_CORE_PRIVATE_FLAG_IS(INITIAL_PUBLISH)) {
        sipe_ocs2005_presence_publish(sipe_private, FALSE);
        /* dalayed run */
        sipe_cal_delayed_calendar_update(sipe_private);
    }
}
コード例 #3
0
ファイル: sipe-ews.c プロジェクト: rravinuthala/sipe
static void
sipe_ews_process_avail_response(int return_code,
				const char *body,
				SIPE_UNUSED_PARAMETER const char *content_type,
				HttpConn *conn,
				void *data)
{
	struct sipe_calendar *cal = data;

	SIPE_DEBUG_INFO_NOFORMAT("sipe_ews_process_avail_response: cb started.");

	if(!sipe_strequal(cal->as_url, cal->oof_url)) { /* whether reuse conn */
		http_conn_set_close(conn);
		cal->http_conn = NULL;
	}

	if (return_code == 200 && body) {
		const sipe_xml *node;
		const sipe_xml *resp;
		/** ref: [MS-OXWAVLS] */
		sipe_xml *xml = sipe_xml_parse(body, strlen(body));
		/*
Envelope/Body/GetUserAvailabilityResponse/FreeBusyResponseArray/FreeBusyResponse/ResponseMessage@ResponseClass="Success"
Envelope/Body/GetUserAvailabilityResponse/FreeBusyResponseArray/FreeBusyResponse/FreeBusyView/MergedFreeBusy
Envelope/Body/GetUserAvailabilityResponse/FreeBusyResponseArray/FreeBusyResponse/FreeBusyView/CalendarEventArray/CalendarEvent
Envelope/Body/GetUserAvailabilityResponse/FreeBusyResponseArray/FreeBusyResponse/FreeBusyView/WorkingHours
		 */
		resp = sipe_xml_child(xml, "Body/GetUserAvailabilityResponse/FreeBusyResponseArray/FreeBusyResponse");
		if (!resp) return; /* rather soap:Fault */
		if (!sipe_strequal(sipe_xml_attribute(sipe_xml_child(resp, "ResponseMessage"), "ResponseClass"), "Success")) {
			return; /* Error response */
		}

		/* MergedFreeBusy */
		g_free(cal->free_busy);
		cal->free_busy = sipe_xml_data(sipe_xml_child(resp, "FreeBusyView/MergedFreeBusy"));

		/* WorkingHours */
		node = sipe_xml_child(resp, "FreeBusyView/WorkingHours");
		g_free(cal->working_hours_xml_str);
		cal->working_hours_xml_str = sipe_xml_stringify(node);
		SIPE_DEBUG_INFO("sipe_ews_process_avail_response: cal->working_hours_xml_str:\n%s",
				cal->working_hours_xml_str ? cal->working_hours_xml_str : "");

		sipe_cal_events_free(cal->cal_events);
		cal->cal_events = NULL;
		/* CalendarEvents */
		for (node = sipe_xml_child(resp, "FreeBusyView/CalendarEventArray/CalendarEvent");
		     node;
		     node = sipe_xml_twin(node))
		{
			char *tmp;
/*
      <CalendarEvent>
	<StartTime>2009-12-07T13:30:00</StartTime>
	<EndTime>2009-12-07T14:30:00</EndTime>
	<BusyType>Busy</BusyType>
	<CalendarEventDetails>
	  <ID>0000000...</ID>
	  <Subject>Lunch</Subject>
	  <Location>Cafe</Location>
	  <IsMeeting>false</IsMeeting>
	  <IsRecurring>true</IsRecurring>
	  <IsException>false</IsException>
	  <IsReminderSet>true</IsReminderSet>
	  <IsPrivate>false</IsPrivate>
	</CalendarEventDetails>
      </CalendarEvent>
*/
			struct sipe_cal_event *cal_event = g_new0(struct sipe_cal_event, 1);
			cal->cal_events = g_slist_append(cal->cal_events, cal_event);

			tmp = sipe_xml_data(sipe_xml_child(node, "StartTime"));
			cal_event->start_time = sipe_utils_str_to_time(tmp);
			g_free(tmp);

			tmp = sipe_xml_data(sipe_xml_child(node, "EndTime"));
			cal_event->end_time = sipe_utils_str_to_time(tmp);
			g_free(tmp);

			tmp = sipe_xml_data(sipe_xml_child(node, "BusyType"));
			if (sipe_strequal("Free", tmp)) {
				cal_event->cal_status = SIPE_CAL_FREE;
			} else if (sipe_strequal("Tentative", tmp)) {
				cal_event->cal_status = SIPE_CAL_TENTATIVE;
			} else if (sipe_strequal("Busy", tmp)) {
				cal_event->cal_status = SIPE_CAL_BUSY;
			} else if (sipe_strequal("OOF", tmp)) {
				cal_event->cal_status = SIPE_CAL_OOF;
			} else {
				cal_event->cal_status = SIPE_CAL_NO_DATA;
			}
			g_free(tmp);

			cal_event->subject = sipe_xml_data(sipe_xml_child(node, "CalendarEventDetails/Subject"));
			cal_event->location = sipe_xml_data(sipe_xml_child(node, "CalendarEventDetails/Location"));

			tmp = sipe_xml_data(sipe_xml_child(node, "CalendarEventDetails/IsMeeting"));
			cal_event->is_meeting = tmp ? sipe_strequal(tmp, "true") : TRUE;
			g_free(tmp);
		}

		sipe_xml_free(xml);

		cal->state = SIPE_EWS_STATE_AVAILABILITY_SUCCESS;
		sipe_ews_run_state_machine(cal);

	} else {
		if (return_code < 0) {