static void
get_cookie (IrisTask *task,
            gpointer  user_data)
{
  MarinaGoogleReaderSourcePrivate *priv;
  SoupMessage *msg;
  gchar       *uri;
  GValue       value = {0,};
  
  g_debug ("get_cookie here");

  g_return_if_fail (IRIS_IS_TASK (task));
  g_return_if_fail (MARINA_IS_GOOGLE_READER_SOURCE (user_data));

  priv = MARINA_GOOGLE_READER_SOURCE (user_data)->priv;

  iris_task_get_result (task, &value);

  if (!G_VALUE_HOLDS_STRING (&value))
    goto cleanup;

  if (!priv->cookie)
    {
g_debug ("%d", __LINE__);
      uri = g_markup_printf_escaped (LOGIN_URI_FORMAT,
                                     priv->username,
                                     g_value_get_string (&value));
      msg = soup_message_new ("GET", uri);
      g_free (uri);
      
      if (soup_session_send_message (priv->session, msg) == 200)
        {
          gchar *tmp = strstr (msg->response_body->data, "SID=");
          if (!tmp)
            ; // set error
          
          gchar *sid = tmp;
          gchar *end = strstr (sid, "\n");
          
          if (!end)
            ; // set error
          
          *end = '\0';
          
          priv->cookie = g_strdup (sid);
          
          g_object_unref (msg);
        }
      else
        {
          // set error
        }
    }
  
  if (priv->cookie)
    IRIS_TASK_RETURN_VALUE (task, G_TYPE_STRING, priv->cookie);

cleanup:
  g_value_unset (&value);
}
Example #2
0
/**
 * iris_progress_monitor_add_watch:
 * @progress_monitor: an #IrisProgressMonitor
 * @task: the #IrisTask that is being watched.
 * @title: name of the task being watched, used to label its progress bar, or
 *         %NULL.
 * @group: #IrisProgressGroup to add the watch to, or %NULL for none
 *
 * Causes @progress_monitor to add a new watch (generally represented by
 * a progress bar) for a task, which needs to update it by posting messages on
 * the #IrisPort that is returned. These messages should be from
 * #IrisProgressMessageType. The watch will be removed when the port receives
 * #IRIS_PROGRESS_MESSAGE_CANCELLED or #IRIS_PROGRESS_MESSAGE_COMPLETE.
 *
 * See iris_progress_monitor_add_group() for more info on watch groups.
 *
 * Returns: an #IrisPort, listening for progress messages.
 */
IrisPort *
iris_progress_monitor_add_watch (IrisProgressMonitor             *progress_monitor,
                                 IrisTask                        *task,
                                 const gchar                     *title,
                                 IrisProgressGroup               *group)
{
	IrisProgressWatch            *watch;
	IrisProgressMonitorInterface *iface;

	g_return_val_if_fail (IRIS_IS_TASK (task), NULL);

	iface = IRIS_PROGRESS_MONITOR_GET_INTERFACE (progress_monitor);

	if (iface->is_watching_task (progress_monitor, task))
		return NULL;

	watch = iris_progress_monitor_add_watch_internal
	          (progress_monitor, task, title, group);

	return watch->port;
}
Example #3
0
/**
 * iris_task_vall_of:
 * @first_task: An #IrisTask
 *
 * Creates a new task that will complete when each of the passed
 * #IrisTask<!-- -->'s complete.
 *
 * Return value: the newly created #IrisTask instance.
 */
IrisTask*
iris_task_vall_of (IrisTask *first_task, ...)
{
	IrisTask *task;
	IrisTask *iter;
	va_list   args;

	if (!first_task)
		return NULL;

	task = iris_task_new ();
	iter = first_task;
	va_start (args, first_task);

	while (iter) {
		if (IRIS_IS_TASK (iter))
			iris_task_add_dependency (task, iter);
		iter = va_arg (args, IrisTask*);
	}

	va_end (args);

	return task;
}