From 208a6ce11b7e79452a432be62bd410fd711a05ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 28 Feb 2006 01:47:26 +0000 Subject: [PATCH] We now set the preferred application of MIME types that are installed from the supported types of an application to the one responsible. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@16542 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/storage/mime/Database.cpp | 44 ++++++++++++++++++------------ 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/kits/storage/mime/Database.cpp b/src/kits/storage/mime/Database.cpp index 28d6b1c45b..74dbdbbc4c 100644 --- a/src/kits/storage/mime/Database.cpp +++ b/src/kits/storage/mime/Database.cpp @@ -486,34 +486,44 @@ Database::SetSupportedTypes(const char *type, const BMessage *types, bool fullSy { DBG(OUT("Database::SetSupportedTypes()\n")); - bool didCreate = false; - status_t err = (type && types) ? B_OK : B_BAD_VALUE; + if (type == NULL || types == NULL) + return B_BAD_VALUE; + // Install the types - if (!err) { - const char *supportedType; - for (int32 i = 0; - err == B_OK - && types->FindString("types", i, &supportedType) == B_OK; - i++) { - if (!is_installed(supportedType)) - err = Install(supportedType); + const char *supportedType; + for (int32 i = 0; types->FindString("types", i, &supportedType) == B_OK; i++) { + if (!is_installed(supportedType)) { + if (Install(supportedType) != B_OK) + break; + + // Since the type has been introduced by this application + // we take the liberty and make it the preferred handler + // for them, too. + SetPreferredApp(supportedType, type, B_OPEN); } } + // Write the attr - if (!err) - err = write_mime_attr_message(type, kSupportedTypesAttr, types, &didCreate); + bool didCreate = false; + status_t status = write_mime_attr_message(type, kSupportedTypesAttr, types, + &didCreate); + // Notify the monitor if we created the type when we opened it - if (!err && didCreate) + if (status == B_OK && didCreate) _SendInstallNotification(type); + // Update the supporting apps map - if (!err) - err = fSupportingApps.SetSupportedTypes(type, types, fullSync); + if (status == B_OK) + status = fSupportingApps.SetSupportedTypes(type, types, fullSync); + // Notify the monitor - if (!err) + if (status == B_OK) _SendMonitorUpdate(B_SUPPORTED_TYPES_CHANGED, type, B_META_MIME_MODIFIED); - return err; + + return status; } + // GetInstalledSupertypes /*! \brief Fetches a BMessage listing all the MIME supertypes currently installed in the MIME database.