Пример #1
0
/**
 * Creates conference.
 */
void
sipe_conf_add(struct sipe_core_private *sipe_private,
	      const gchar* who)
{
	gchar *hdr;
	gchar *conference_id;
	gchar *contact;
	gchar *body;
	gchar *self;
	struct transaction *trans;
	struct sip_dialog *dialog = NULL;
	time_t expiry = time(NULL) + 7*60*60; /* 7 hours */
	char *expiry_time;
	struct transaction_payload *payload;

	contact = get_contact(sipe_private);
	hdr = g_strdup_printf(
		"Supported: ms-sender\r\n"
		"Contact: %s\r\n"
		"Content-Type: application/cccp+xml\r\n",
		contact);
	g_free(contact);

	expiry_time = sipe_utils_time_to_str(expiry);
	self = sip_uri_self(sipe_private);
	conference_id = genconfid();
	body = g_strdup_printf(
		SIPE_SEND_CONF_ADD,
		sipe_private->focus_factory_uri,
		self,
		rand(),
		conference_id,
		expiry_time);
	g_free(self);
	g_free(conference_id);
	g_free(expiry_time);

	trans = sip_transport_service(sipe_private,
				      sipe_private->focus_factory_uri,
				      hdr,
				      body,
				      process_conf_add_response);

	payload = g_new0(struct transaction_payload, 1);
	payload->destroy = g_free;
	payload->data = g_strdup(who);
	trans->payload = payload;

	sipe_dialog_free(dialog);
	g_free(body);
	g_free(hdr);
}
Пример #2
0
static void send_presence_soap(struct sipe_core_private *sipe_private,
                               gboolean do_publish_calendar,
                               gboolean do_reset_status)
{
    struct sipe_calendar* cal = sipe_private->calendar;
    gchar *body;
    gchar *tmp;
    gchar *tmp2 = NULL;
    gchar *res_note = NULL;
    gchar *res_oof = NULL;
    const gchar *note_pub = NULL;
    gchar *states = NULL;
    gchar *calendar_data = NULL;
    gchar *epid = get_epid(sipe_private);
    gchar *from = sip_uri_self(sipe_private);
    time_t now = time(NULL);
    gchar *since_time_str = sipe_utils_time_to_str(now);
    const gchar *oof_note = cal ? sipe_ews_get_oof_note(cal) : NULL;
    const char *user_input;
    gboolean pub_oof = cal && oof_note && (!sipe_private->note || cal->updated > sipe_private->note_since);

    if (oof_note && sipe_private->note) {
        SIPE_DEBUG_INFO("cal->oof_start           : %s", asctime(localtime(&(cal->oof_start))));
        SIPE_DEBUG_INFO("sipe_private->note_since : %s", asctime(localtime(&(sipe_private->note_since))));
    }

    SIPE_DEBUG_INFO("sipe_private->note  : %s", sipe_private->note ? sipe_private->note : "");

    if (!SIPE_CORE_PRIVATE_FLAG_IS(INITIAL_PUBLISH) ||
            do_reset_status)
        sipe_status_set_activity(sipe_private, SIPE_ACTIVITY_AVAILABLE);

    /* Note */
    if (pub_oof) {
        note_pub = oof_note;
        res_oof = SIPE_SOAP_SET_PRESENCE_OOF_XML;
        cal->published = TRUE;
    } else if (sipe_private->note) {
        if (SIPE_CORE_PRIVATE_FLAG_IS(OOF_NOTE) &&
                !oof_note) { /* stale OOF note, as it's not present in cal already */
            g_free(sipe_private->note);
            sipe_private->note = NULL;
            SIPE_CORE_PRIVATE_FLAG_UNSET(OOF_NOTE);
            sipe_private->note_since = 0;
        } else {
            note_pub = sipe_private->note;
            res_oof = SIPE_CORE_PRIVATE_FLAG_IS(OOF_NOTE) ? SIPE_SOAP_SET_PRESENCE_OOF_XML : "";
        }
    }

    if (note_pub)
    {
        /* to protocol internal plain text format */
        tmp = sipe_backend_markup_strip_html(note_pub);
        res_note = g_markup_printf_escaped(SIPE_SOAP_SET_PRESENCE_NOTE_XML, tmp);
        g_free(tmp);
    }

    /* User State */
    if (!do_reset_status) {
        if (sipe_status_changed_by_user(sipe_private) &&
                !do_publish_calendar &&
                SIPE_CORE_PRIVATE_FLAG_IS(INITIAL_PUBLISH)) {
            const gchar *activity_token;
            int avail_2007 = sipe_ocs2007_availability_from_status(sipe_private->status,
                             &activity_token);

            states = g_strdup_printf(SIPE_SOAP_SET_PRESENCE_STATES,
                                     avail_2007,
                                     since_time_str,
                                     epid,
                                     activity_token);
        }
        else /* preserve existing publication */
        {
            if (sipe_private->ocs2005_user_states) {
                states = g_strdup(sipe_private->ocs2005_user_states);
            }
        }
    } else {
        /* do nothing - then User state will be erased */
    }
    SIPE_CORE_PRIVATE_FLAG_SET(INITIAL_PUBLISH);

    /* CalendarInfo */
    if (cal && (!is_empty(cal->legacy_dn) || !is_empty(cal->email)) && cal->fb_start && !is_empty(cal->free_busy))
    {
        char *fb_start_str = sipe_utils_time_to_str(cal->fb_start);
        char *free_busy_base64 = sipe_cal_get_freebusy_base64(cal->free_busy);
        calendar_data = g_strdup_printf(SIPE_SOAP_SET_PRESENCE_CALENDAR,
                                        !is_empty(cal->legacy_dn) ? cal->legacy_dn : cal->email,
                                        fb_start_str,
                                        free_busy_base64);
        g_free(fb_start_str);
        g_free(free_busy_base64);
    }

    user_input = (sipe_status_changed_by_user(sipe_private) ||
                  sipe_is_user_available(sipe_private)) ?
                 "active" : "idle";

    /* generate XML */
    body = g_strdup_printf(SIPE_SOAP_SET_PRESENCE,
                           sipe_private->username,
                           sipe_ocs2005_availability_from_status(sipe_private),
                           sipe_ocs2005_activity_from_status(sipe_private),
                           (tmp = g_ascii_strup(g_get_host_name(), -1)),
                           res_note ? res_note : "",
                           res_oof ? res_oof : "",
                           states ? states : "",
                           calendar_data ? calendar_data : "",
                           epid,
                           since_time_str,
                           since_time_str,
                           user_input);
    g_free(tmp);
    g_free(tmp2);
    g_free(res_note);
    g_free(states);
    g_free(calendar_data);
    g_free(since_time_str);
    g_free(epid);

    sip_soap_raw_request_cb(sipe_private, from, body, NULL, NULL);

    g_free(body);
}