Less hardcoding of paths. Adding shared private OpenWithTracker().
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33207 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
7629e48591
commit
7914280cb8
66
headers/private/shared/OpenWithTracker.h
Normal file
66
headers/private/shared/OpenWithTracker.h
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 2009 Haiku Inc.
|
||||
* All rights reserved. Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef _OPEN_WITH_TRACKER_H
|
||||
#define _OPEN_WITH_TRACKER_H
|
||||
|
||||
|
||||
#include <Entry.h>
|
||||
#include <FindDirectory.h>
|
||||
#include <Message.h>
|
||||
#include <Messenger.h>
|
||||
#include <Path.h>
|
||||
|
||||
|
||||
status_t
|
||||
OpenWithTracker(const entry_ref* ref)
|
||||
{
|
||||
status_t status;
|
||||
BMessage message(B_REFS_RECEIVED);
|
||||
message.AddRef("refs", ref);
|
||||
|
||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||
status = tracker.SendMessage(&message);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
OpenWithTracker(const char* path)
|
||||
{
|
||||
status_t status;
|
||||
entry_ref ref;
|
||||
status = get_ref_for_path(path, &ref);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return OpenWithTracker(&ref);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
OpenWithTracker(directory_which which, const char* relativePath,
|
||||
bool createDirectory = false, BVolume* volume = NULL)
|
||||
{
|
||||
status_t status;
|
||||
BPath path;
|
||||
find_directory(which, &path, createDirectory, volume);
|
||||
path.Append(relativePath);
|
||||
|
||||
entry_ref ref;
|
||||
BEntry entry(path.Path());
|
||||
|
||||
if (!entry.Exists())
|
||||
return B_NAME_NOT_FOUND;
|
||||
|
||||
status = entry.GetRef(&ref);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
|
||||
return OpenWithTracker(&ref);
|
||||
}
|
||||
|
||||
|
||||
#endif // _OPEN_WITH_TRACKER_H
|
||||
|
@ -93,7 +93,8 @@ const char* kSpamServerSignature =
|
||||
const char* kDraftPath = "mail/draft";
|
||||
const char* kDraftType = "text/x-vnd.Be-MailDraft";
|
||||
const char* kMailFolder = "mail";
|
||||
const char* kMailboxFolder = "config/settings/Mail/mailbox";
|
||||
const char* kMailboxSymlink = "Mail/mailbox";
|
||||
// relative to B_USER_SETTINGS_DIRECTORY
|
||||
|
||||
|
||||
int32
|
||||
|
@ -79,7 +79,8 @@ extern const char* kSpamServerSignature;
|
||||
extern const char* kDraftPath;
|
||||
extern const char* kDraftType;
|
||||
extern const char* kMailFolder;
|
||||
extern const char* kMailboxFolder;
|
||||
extern const char* kMailboxSymlink;
|
||||
|
||||
|
||||
#endif // _MAIL_SUPPORT_H
|
||||
|
||||
|
@ -48,6 +48,7 @@ All rights reserved.
|
||||
#include <Debug.h>
|
||||
#include <E-mail.h>
|
||||
#include <InterfaceKit.h>
|
||||
#include <OpenWithTracker.h>
|
||||
#ifdef __HAIKU__
|
||||
# include <PathMonitor.h>
|
||||
#endif
|
||||
@ -1475,29 +1476,13 @@ TMailWindow::MessageReceived(BMessage *msg)
|
||||
break;
|
||||
|
||||
case M_OPEN_MAIL_FOLDER:
|
||||
case M_OPEN_MAIL_BOX:
|
||||
{
|
||||
BEntry folderEntry;
|
||||
BPath path;
|
||||
// Get the user home directory
|
||||
if (find_directory(B_USER_DIRECTORY, &path) != B_OK)
|
||||
break;
|
||||
if (msg->what == M_OPEN_MAIL_FOLDER)
|
||||
path.Append(kMailFolder);
|
||||
else
|
||||
path.Append(kMailboxFolder);
|
||||
if (folderEntry.SetTo(path.Path()) == B_OK && folderEntry.Exists())
|
||||
{
|
||||
BMessage thePackage(B_REFS_RECEIVED);
|
||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||
|
||||
entry_ref ref;
|
||||
folderEntry.GetRef(&ref);
|
||||
thePackage.AddRef("refs", &ref);
|
||||
tracker.SendMessage(&thePackage);
|
||||
}
|
||||
OpenWithTracker(B_USER_DIRECTORY, kMailFolder);
|
||||
break;
|
||||
}
|
||||
|
||||
case M_OPEN_MAIL_BOX:
|
||||
OpenWithTracker(B_USER_SETTINGS_DIRECTORY, kMailboxSymlink);
|
||||
break;
|
||||
|
||||
case RESET_BUTTONS:
|
||||
fChanged = false;
|
||||
fFieldState = 0;
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <Messenger.h>
|
||||
#include <NodeInfo.h>
|
||||
#include <NodeMonitor.h>
|
||||
#include <OpenWithTracker.h>
|
||||
#include <Path.h>
|
||||
#include <PopUpMenu.h>
|
||||
#include <Query.h>
|
||||
@ -196,28 +197,6 @@ void DeskbarView::Draw(BRect /*updateRect*/)
|
||||
}
|
||||
|
||||
|
||||
status_t OpenFolder(const char* end)
|
||||
{
|
||||
BPath path;
|
||||
find_directory(B_USER_DIRECTORY, &path);
|
||||
path.Append(end);
|
||||
|
||||
entry_ref ref;
|
||||
if (get_ref_for_path(path.Path(), &ref) != B_OK)
|
||||
return B_NAME_NOT_FOUND;
|
||||
|
||||
if (!BEntry(&ref).Exists())
|
||||
return B_NAME_NOT_FOUND;
|
||||
|
||||
BMessage open_mbox(B_REFS_RECEIVED);
|
||||
open_mbox.AddRef("refs",&ref);
|
||||
|
||||
BMessenger tracker("application/x-vnd.Be-TRAK");
|
||||
tracker.SendMessage(&open_mbox);
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
DeskbarView::MessageReceived(BMessage* message)
|
||||
{
|
||||
@ -344,10 +323,9 @@ void
|
||||
DeskbarView::MouseUp(BPoint pos)
|
||||
{
|
||||
if (fLastButtons & B_PRIMARY_MOUSE_BUTTON) {
|
||||
if (OpenFolder("config/settings/Mail/mailbox") != B_OK
|
||||
&& OpenFolder("mail/in") != B_OK
|
||||
&& OpenFolder("mail/INBOX") != B_OK)
|
||||
OpenFolder("mail");
|
||||
if (OpenWithTracker(B_USER_SETTINGS_DIRECTORY, "Mail/mailbox") != B_OK
|
||||
&& OpenWithTracker(B_USER_DIRECTORY, "mail/in") != B_OK)
|
||||
OpenWithTracker(B_USER_DIRECTORY, "mail");
|
||||
}
|
||||
|
||||
if (fLastButtons & B_TERTIARY_MOUSE_BUTTON)
|
||||
|
@ -8,6 +8,7 @@ if $(TARGET_PLATFORM) != haiku {
|
||||
|
||||
UsePublicHeaders [ FDirName add-ons mail_daemon ] ;
|
||||
UsePrivateHeaders mail ;
|
||||
UsePrivateHeaders shared ;
|
||||
UseLibraryHeaders icon ;
|
||||
|
||||
SubDirHdrs [ FDirName $(HAIKU_TOP) headers os add-ons mail_daemon ] ;
|
||||
|
Loading…
Reference in New Issue
Block a user