Пример #1
0
int
ACEXML_HttpCharStream::send_request (void)
{
  char* path = ACE::strnew (ACE_TEXT_ALWAYS_CHAR (this->url_addr_->get_path_name()));
  ACE_Auto_Basic_Array_Ptr<char> path_ptr (path);
  size_t commandsize = ACE_OS::strlen (path)
                       + ACE_OS::strlen (this->url_addr_->get_host_name ())
                       + 20     // Extra
                       + 1      // NUL byte
                       + 16 ;   // Protocol filler...

  char* command;
  ACE_NEW_RETURN (command, char[commandsize], -1);

  // Ensure that the <command> memory is deallocated.
  ACE_Auto_Basic_Array_Ptr<char> cmd_ptr (command);

  int bytes = ACE_OS::sprintf (command, "GET %s HTTP/1.0\r\n", path);
  bytes += ACE_OS::sprintf (&command[bytes], "Host: %s\r\n",
                            this->url_addr_->get_host_name ());
  bytes += ACE_OS::sprintf (&command[bytes], "\r\n");

  ACE_Time_Value tv (ACE_DEFAULT_TIMEOUT);

  // Send the command to the connected server.
  int retval = static_cast<int> (this->stream_->send_n (command, bytes, &tv));
  if (retval <= 0)
    return -1;
  return retval;
}
Пример #2
0
static gint
userlist_click_cb (GtkWidget *widget, GdkEventButton *event, gpointer userdata)
{
	if (!event)
		return FALSE;

	if (!(event->state & STATE_CTRL) &&
		event->type == GDK_2BUTTON_PRESS && prefs.hex_gui_ulist_doubleclick[0])
	{
		auto nicks = userlist_selection_list (widget);
		if (!nicks.empty())
		{
			nick_command_parse (current_sess, prefs.hex_gui_ulist_doubleclick, nicks[0],
									  nicks[0]);
		}
		return TRUE;
	}

	if (event->button == 3)
	{
		/* do we have a multi-selection? */
		auto nicks = userlist_selection_list (widget);
		if (!nicks.empty())
		{
			menu_nickmenu (current_sess, event, nicks[0], nicks.size());
			return TRUE;
		}

		auto sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));
		GtkTreePath *path;
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
			 event->x, event->y, &path, 0, 0, 0))
		{
			GtkTreePathPtr path_ptr(path);
			gtk_tree_selection_unselect_all (sel);
			gtk_tree_selection_select_path (sel, path);
			nicks = userlist_selection_list (widget);
			if (!nicks.empty())
			{
				menu_nickmenu (current_sess, event, nicks[0], nicks.size());
			}
		} else
		{
			gtk_tree_selection_unselect_all (sel);
		}

		return TRUE;
	}

	return FALSE;
}
Пример #3
0
static gboolean
userlist_dnd_motion (GtkTreeView *widget, GdkDragContext *context, gint x,
							gint y, guint ttime, gpointer tree)
{
	if (!tree)
		return FALSE;

	GtkTreePath *path;
	if (gtk_tree_view_get_path_at_pos (widget, x, y, &path, NULL, NULL, NULL))
	{
		GtkTreePathPtr path_ptr(path);
		auto sel = gtk_tree_view_get_selection (widget);
		gtk_tree_selection_unselect_all (sel);
		gtk_tree_selection_select_path (sel, path);
	}

	return FALSE;
}
Пример #4
0
	path_t::path_t(atma::string const& str, atma::string::const_iterator const& begin)
	{
		char const* delims = "/\\";

		auto end = atma::find_first_of(str, begin, delims);
		if (end == str.end()) {
			type_ = path_type_t::file;
		}
		else {
			type_ = path_type_t::dir;
			++end;
		}

		name_ = atma::string(begin, end);

		if (end == begin)
			return;

		child_ = path_ptr(new path_t(str, end));
	}
Пример #5
0
static void
userlist_dnd_drop (GtkTreeView *widget, GdkDragContext *context,
						 gint x, gint y, GtkSelectionData *selection_data,
						 guint info, guint ttime, gpointer userdata)
{
	struct User *user;
	GtkTreePath *path;
	if (!gtk_tree_view_get_path_at_pos (widget, x, y, &path, NULL, NULL, NULL))
		return;

	GtkTreePathPtr path_ptr(path);
	auto model = gtk_tree_view_get_model (widget);
	GtkTreeIter iter;
	if (!gtk_tree_model_get_iter (model, &iter, path))
		return;
	gtk_tree_model_get (model, &iter, COL_USER, &user, -1);

	auto data = gtk_selection_data_get_data (selection_data);

	if (data)
		mg_dnd_drop_file (current_sess, user->nick.c_str(), reinterpret_cast<const char*>(data));
}
Пример #6
0
	path_t::path_t(path_t const& rhs)
		: name_(rhs.name_), type_(rhs.type_)
	{
		if (rhs.child_)
			child_ = path_ptr(new path_t(*rhs.child_));
	}