Beispiel #1
0
filter_result
DCCFileFilter::HandleButton (BMessage *)
{
	filter_result result (B_DISPATCH_MESSAGE);
	BTextControl *paneltext (dynamic_cast<BTextControl *>(
		panel->Window()->FindView ("text view")));
    
	if (paneltext)
	{
		BDirectory dir;
		struct stat s;
		entry_ref ref;
		BEntry entry;

		panel->GetPanelDirectory (&ref);

		dir.SetTo (&ref);
		
		if (entry.SetTo (&dir, paneltext->Text()) == B_NO_ERROR
		&&  entry.GetStat (&s)               == B_NO_ERROR
		&&  S_ISREG (s.st_mode))
		{
          if (vision_app->GetBool ("dccAutoAccept"))
          {
            BMessage msg (M_FILE_PANEL_ALERT);
            msg.AddInt32 ("which", 2);
            panel->Window()->PostMessage (&msg);
            result = B_SKIP_MESSAGE; 
          }
          else
          {
			BString buffer;
			BAlert *alert;

			buffer << "The file \""
				<< paneltext->Text()
				<< "\" already exists in the specified folder.  "
					"Do you want to continue the transfer?";

			alert = new BAlert (
				"DCC Request",
				buffer.String(),
				"Cancel",
				"Replace",
				"Resume",
				B_WIDTH_AS_USUAL,
				B_OFFSET_SPACING,
				B_WARNING_ALERT);

			alert->Go (new BInvoker (
				new BMessage (M_FILE_PANEL_ALERT),
				panel->Window()));

			result = B_SKIP_MESSAGE;
	      }
		}
	}
	return result;
}
Beispiel #2
0
filter_result
DCCFileFilter::HandleAlert (BMessage *msg)
{
	BTextControl *text (dynamic_cast<BTextControl *>(
		panel->Window()->FindView ("text view")));
	int32 which;

	msg->FindInt32 ("which", &which);

	if (which == 0 || text == 0)
	{
		return B_SKIP_MESSAGE;
	}

	entry_ref ref;
	panel->GetPanelDirectory (&ref);

	if (which == 2)
	{
		BDirectory dir (&ref);
		BFile file (&dir, text->Text(), B_READ_ONLY);
		BEntry entry (&dir, text->Text());
		BPath path;
		off_t position;

		file.GetSize (&position);
		entry.GetPath (&path);
		send_msg.AddString ("path", path.Path());
		send_msg.AddInt64  ("pos", position);

		send_msg.what = M_ADD_RESUME_DATA;
	}
	else
	{
		send_msg.AddRef ("directory", &ref);
		send_msg.AddString ("name", text->Text());
	}

	panel->Messenger().SendMessage (&send_msg);

	BMessage cmsg (B_CANCEL);
	cmsg.AddPointer ("source", panel);
	panel->Messenger().SendMessage (&cmsg);

	return B_SKIP_MESSAGE;
}