diff --git a/sources/AutoFiler.cpp b/sources/AutoFiler.cpp index e861628..72147f3 100644 --- a/sources/AutoFiler.cpp +++ b/sources/AutoFiler.cpp @@ -3,14 +3,18 @@ Written by DarkWyrm , Copyright 2008 Released under the MIT license. */ -#include "AutoFiler.h" + #include #include #include + +#include "AutoFiler.h" +#include "FilerDefs.h" #include "RefStorage.h" -App::App(void) - : BApplication("application/x-vnd.dw-AutoFiler") +App::App() + : + BApplication(kAutoFilerSignature) { LoadFolders(); StartWatching(); @@ -18,11 +22,11 @@ App::App(void) void -App::MessageReceived(BMessage *msg) +App::MessageReceived(BMessage* msg) { switch(msg->what) { - case M_REFRESH_FOLDERS: + case MSG_REFRESH_FOLDERS: { StopWatching(); ReloadFolders(); @@ -42,14 +46,14 @@ App::MessageReceived(BMessage *msg) void -App::StartWatching(void) +App::StartWatching() { gRefLock.Lock(); for (int32 i = 0; i < gRefStructList.CountItems(); i++) { - RefStorage *refholder = (RefStorage*)gRefStructList.ItemAt(i); - watch_node(&refholder->nref,B_WATCH_ALL,this); + RefStorage* refholder = (RefStorage*)gRefStructList.ItemAt(i); + watch_node(&refholder->nref, B_WATCH_ALL, this); } gRefLock.Unlock(); @@ -57,10 +61,10 @@ App::StartWatching(void) void -App::HandleNodeMonitoring(BMessage *msg) +App::HandleNodeMonitoring(BMessage* msg) { int32 op; - msg->FindInt32("opcode",&op); + msg->FindInt32("opcode", &op); switch (op) { @@ -69,14 +73,14 @@ App::HandleNodeMonitoring(BMessage *msg) BString name; entry_ref ref; - msg->FindInt32("device",&ref.device); - msg->FindInt64("directory",&ref.directory); - msg->FindString("name",&name); + msg->FindInt32("device", &ref.device); + msg->FindInt64("directory", &ref.directory); + msg->FindString("name", &name); ref.set_name(name.String()); BMessage args(B_REFS_RECEIVED); - args.AddRef("refs",&ref); - be_roster->Launch("application/x-vnd.dw-Filer",&args); + args.AddRef("refs", &ref); + be_roster->Launch(kFilerSignature, &args); break; } case B_ENTRY_MOVED: @@ -84,15 +88,15 @@ App::HandleNodeMonitoring(BMessage *msg) // We only care if we're monitoring the "to" directory because // the Filer doesn't care about files that aren't there anymore node_ref nref; - msg->FindInt32("device",&nref.device); - msg->FindInt64("to directory",&nref.node); + msg->FindInt32("device", &nref.device); + msg->FindInt64("to directory", &nref.node); gRefLock.Lock(); bool match = false; for (int32 i = 0; i < gRefStructList.CountItems(); i++) { - RefStorage *refholder = (RefStorage*)gRefStructList.ItemAt(i); + RefStorage* refholder = (RefStorage*)gRefStructList.ItemAt(i); if (nref == refholder->nref) { match = true; @@ -106,14 +110,14 @@ App::HandleNodeMonitoring(BMessage *msg) { BString name; entry_ref ref; - msg->FindString("name",&name); + msg->FindString("name", &name); ref.device = nref.device; ref.directory = nref.node; ref.set_name(name.String()); BMessage args(B_REFS_RECEIVED); - args.AddRef("refs",&ref); - be_roster->Launch("application/x-vnd.dw-Filer",&args); + args.AddRef("refs", &ref); + be_roster->Launch(kFilerSignature, &args); } break; } @@ -121,8 +125,8 @@ App::HandleNodeMonitoring(BMessage *msg) case B_ATTR_CHANGED: { node_ref nref; - msg->FindInt32("device",&nref.device); - msg->FindInt64("node",&nref.node); + msg->FindInt32("device", &nref.device); + msg->FindInt64("node", &nref.node); gRefLock.Lock(); @@ -130,7 +134,7 @@ App::HandleNodeMonitoring(BMessage *msg) entry_ref ref; for (int32 i = 0; i < gRefStructList.CountItems(); i++) { - RefStorage *refholder = (RefStorage*)gRefStructList.ItemAt(i); + RefStorage* refholder = (RefStorage*)gRefStructList.ItemAt(i); if (nref == refholder->nref) { ref = refholder->ref; @@ -144,8 +148,8 @@ App::HandleNodeMonitoring(BMessage *msg) if (match) { BMessage args(B_REFS_RECEIVED); - args.AddRef("refs",&ref); - be_roster->Launch("application/x-vnd.dw-Filer",&args); + args.AddRef("refs", &ref); + be_roster->Launch(kFilerSignature, &args); } break; } @@ -156,16 +160,16 @@ App::HandleNodeMonitoring(BMessage *msg) void -App::StopWatching(void) +App::StopWatching() { stop_watching(this); } int -main(int argc, char **argv) +main(int argc, char** argv) { - App *app = new App; + App* app = new App; app->Run(); delete app; diff --git a/sources/AutoFiler.h b/sources/AutoFiler.h index 493dca8..0fc6bdf 100644 --- a/sources/AutoFiler.h +++ b/sources/AutoFiler.h @@ -3,8 +3,9 @@ Written by DarkWyrm , Copyright 2008 Released under the MIT license. */ -#ifndef MAIN_H -#define MAIN_H + +#ifndef AUTOFILER_H +#define AUTOFILER_H #include #include @@ -12,13 +13,13 @@ class App : public BApplication { public: - App(void); - void MessageReceived(BMessage *msg); + App(); + void MessageReceived(BMessage* msg); private: - void HandleNodeMonitoring(BMessage *msg); - void StartWatching(void); - void StopWatching(void); + void HandleNodeMonitoring(BMessage* msg); + void StartWatching(); + void StopWatching(); }; -#endif +#endif // AUTOFILER_H diff --git a/sources/RefStorage.cpp b/sources/RefStorage.cpp index 3067da5..86a36df 100644 --- a/sources/RefStorage.cpp +++ b/sources/RefStorage.cpp @@ -61,7 +61,7 @@ LoadFolders() entry_ref tempRef; int32 i = 0; - while (msg.FindRef("refs",i,&tempRef) == B_OK) + while (msg.FindRef("refs", i, &tempRef) == B_OK) { i++; RefStorage* refholder = new RefStorage(tempRef); diff --git a/sources/RefStorage.h b/sources/RefStorage.h index 16a1237..8b7b1fd 100644 --- a/sources/RefStorage.h +++ b/sources/RefStorage.h @@ -11,10 +11,6 @@ extern BList gRefStructList; extern BLocker gRefLock; extern const char gPrefsPath[]; -enum -{ - M_REFRESH_FOLDERS = 'rffl' -}; class RefStorage {