2002-08-27 12:26:11 +04:00
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// This software is part of the OpenBeOS distribution and is covered
|
|
|
|
// by the OpenBeOS license.
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
/*!
|
|
|
|
\file Database.cpp
|
|
|
|
Database class declarations
|
|
|
|
*/
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
|
|
|
|
#ifndef _MIME_DATABASE_H
|
|
|
|
#define _MIME_DATABASE_H
|
|
|
|
|
2002-09-24 09:36:03 +04:00
|
|
|
#include <Mime.h>
|
|
|
|
#include <mime/AssociatedTypes.h>
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
#include <mime/InstalledTypes.h>
|
2002-09-24 09:36:03 +04:00
|
|
|
#include <mime/SnifferRules.h>
|
2002-08-29 03:57:30 +04:00
|
|
|
#include <mime/SupportingApps.h>
|
2002-09-24 09:36:03 +04:00
|
|
|
#include <mime/database_access.h>
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
#include <Messenger.h>
|
|
|
|
#include <StorageDefs.h>
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
class BNode;
|
|
|
|
class BBitmap;
|
|
|
|
class BMessage;
|
2002-09-24 09:36:03 +04:00
|
|
|
class BString;
|
|
|
|
|
|
|
|
struct entry_ref;
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
namespace Storage {
|
|
|
|
namespace Mime {
|
|
|
|
|
2002-09-29 11:12:42 +04:00
|
|
|
// types of mime update functions that may be run asynchronously
|
|
|
|
typedef enum {
|
|
|
|
B_REG_UPDATE_MIME_INFO,
|
|
|
|
B_REG_CREATE_APP_META_MIME,
|
|
|
|
} mime_update_function;
|
|
|
|
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
class Database {
|
|
|
|
public:
|
|
|
|
Database();
|
|
|
|
~Database();
|
|
|
|
|
|
|
|
status_t InitCheck() const;
|
|
|
|
|
|
|
|
// Type management
|
|
|
|
status_t Install(const char *type);
|
|
|
|
status_t Delete(const char *type);
|
|
|
|
|
|
|
|
// Set()
|
|
|
|
status_t SetAppHint(const char *type, const entry_ref *ref);
|
|
|
|
status_t SetAttrInfo(const char *type, const BMessage *info);
|
|
|
|
status_t SetShortDescription(const char *type, const char *description);
|
|
|
|
status_t SetLongDescription(const char *type, const char *description);
|
|
|
|
status_t SetFileExtensions(const char *type, const BMessage *extensions);
|
|
|
|
status_t SetIcon(const char *type, const void *data, size_t dataSize, icon_size which);
|
|
|
|
status_t SetIconForType(const char *type, const char *fileType, const void *data,
|
|
|
|
size_t dataSize, icon_size which);
|
|
|
|
status_t SetPreferredApp(const char *type, const char *signature, app_verb verb = B_OPEN);
|
2002-09-09 12:12:03 +04:00
|
|
|
status_t SetSnifferRule(const char *type, const char *rule);
|
2002-08-29 03:57:30 +04:00
|
|
|
status_t SetSupportedTypes(const char *type, const BMessage *types, bool fullSync);
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
|
|
|
|
// Non-atomic Get()
|
|
|
|
status_t GetInstalledSupertypes(BMessage *super_types);
|
|
|
|
status_t GetInstalledTypes(BMessage *types);
|
|
|
|
status_t GetInstalledTypes(const char *super_type,
|
|
|
|
BMessage *subtypes);
|
|
|
|
status_t GetSupportingApps(const char *type, BMessage *signatures);
|
2002-09-24 09:36:03 +04:00
|
|
|
status_t GetAssociatedTypes(const char *extension, BMessage *types);
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
|
|
|
|
// Sniffer
|
2002-09-24 09:36:03 +04:00
|
|
|
status_t GuessMimeType(const entry_ref *file, BString *result);
|
|
|
|
status_t GuessMimeType(const void *buffer, int32 length, BString *result);
|
|
|
|
status_t GuessMimeType(const char *filename, BString *result);
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
|
|
|
|
// Monitor
|
|
|
|
status_t StartWatching(BMessenger target);
|
|
|
|
status_t StopWatching(BMessenger target);
|
|
|
|
|
|
|
|
// Delete()
|
|
|
|
status_t DeleteAppHint(const char *type);
|
|
|
|
status_t DeleteAttrInfo(const char *type);
|
|
|
|
status_t DeleteShortDescription(const char *type);
|
|
|
|
status_t DeleteLongDescription(const char *type);
|
|
|
|
status_t DeleteFileExtensions(const char *type);
|
|
|
|
status_t DeleteIcon(const char *type, icon_size size);
|
|
|
|
status_t DeleteIconForType(const char *type, const char *fileType, icon_size which);
|
|
|
|
status_t DeletePreferredApp(const char *type, app_verb verb = B_OPEN);
|
|
|
|
status_t DeleteSnifferRule(const char *type);
|
2002-09-09 12:12:03 +04:00
|
|
|
status_t DeleteSupportedTypes(const char *type, bool fullSync);
|
2002-09-24 09:36:03 +04:00
|
|
|
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
private:
|
2002-09-24 09:36:03 +04:00
|
|
|
// Functions to send monitor notifications
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
status_t SendInstallNotification(const char *type);
|
|
|
|
status_t SendDeleteNotification(const char *type);
|
|
|
|
status_t SendMonitorUpdate(int32 which, const char *type, const char *extraType,
|
|
|
|
bool largeIcon, int32 action);
|
|
|
|
status_t SendMonitorUpdate(int32 which, const char *type, const char *extraType,
|
|
|
|
int32 action);
|
|
|
|
status_t SendMonitorUpdate(int32 which, const char *type, bool largeIcon,
|
|
|
|
int32 action);
|
|
|
|
status_t SendMonitorUpdate(int32 which, const char *type,
|
|
|
|
int32 action);
|
|
|
|
status_t SendMonitorUpdate(BMessage &msg);
|
|
|
|
|
2002-09-29 11:12:42 +04:00
|
|
|
status_t fStatus;
|
2002-08-29 03:57:30 +04:00
|
|
|
std::set<BMessenger> fMonitorMessengers;
|
2002-09-24 09:36:03 +04:00
|
|
|
AssociatedTypes fAssociatedTypes;
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
InstalledTypes fInstalledTypes;
|
2002-09-24 09:36:03 +04:00
|
|
|
SnifferRules fSnifferRules;
|
2002-08-29 03:57:30 +04:00
|
|
|
SupportingApps fSupportingApps;
|
After implementing the BMimeType::GetInstalled[Super]Types()
functionality, it became apparent that some restructuring was
needed if I wanted to keep things clean and managble.
storage/MimeDatabase.{h,cpp} have been broken into:
storage/mime/database_support.{h,cpp}
+ MIME database constants
+ high-level database access functions like open_type(),
read_mime_attr(), etc.
storage/mime/database_access.{h,cpp}
+ atomic read functions
+ is_installed()
+ get_icon_data()
storage/mime/Database.{h,cpp}
+ Mime::Database class, which is responsible for all write,
non-atomic read, and mime monitor functionality.
storage/mime/InstalledTypes.{h,cpp}
+ Helper class for Mime::Database::GetInstalled[Super]Types()
storage/mime/Supertype.{h,cpp}
+ Helper class for Mime::InstalledTypes
I haven't merged my intial, somewhat cludgy GetInstalled[Super]Types
implementation into the new setup yet. That comes next, and it ought
to be a more graceful implementation now.
I also implemented BMimeType::Get/SetSupportingTypes(), though
they haven't been tested yet (sorry).
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@862 a95241bf-73f2-0310-859d-f6bbb57e9c96
2002-08-24 09:04:02 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace Mime
|
|
|
|
} // namespace Storage
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
#endif // _MIME_DATABASE_H
|