Localization of mount_server based on a patch by Jorma Karvonen (ticket #6063),

thanks a lot!


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36924 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2010-05-24 14:43:09 +00:00
parent a3d9c49a18
commit 3f027ce92a
2 changed files with 79 additions and 49 deletions
+71 -47
View File
@@ -1,8 +1,9 @@
/* /*
* Copyright 2007-2009, Haiku, Inc. All rights reserved. * Copyright 2007-2010, Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
#include "AutoMounter.h" #include "AutoMounter.h"
#include <new> #include <new>
@@ -12,6 +13,7 @@
#include <Alert.h> #include <Alert.h>
#include <AutoLocker.h> #include <AutoLocker.h>
#include <Catalog.h>
#include <Debug.h> #include <Debug.h>
#include <Directory.h> #include <Directory.h>
#include <DiskDevice.h> #include <DiskDevice.h>
@@ -22,6 +24,7 @@
#include <FindDirectory.h> #include <FindDirectory.h>
#include <fs_info.h> #include <fs_info.h>
#include <fs_volume.h> #include <fs_volume.h>
#include <Locale.h>
#include <Message.h> #include <Message.h>
#include <Node.h> #include <Node.h>
#include <NodeMonitor.h> #include <NodeMonitor.h>
@@ -34,6 +37,10 @@
#include "MountServer.h" #include "MountServer.h"
#undef B_TRANSLATE_CONTEXT
#define B_TRANSLATE_CONTEXT "AutoMounter"
static const char* kMountServerSettings = "mount_server"; static const char* kMountServerSettings = "mount_server";
static const uint32 kMsgInitialScan = 'insc'; static const uint32 kMsgInitialScan = 'insc';
static const char* kMountFlagsKeyExtension = " mount flags"; static const char* kMountFlagsKeyExtension = " mount flags";
@@ -163,7 +170,8 @@ AutoMounter::MessageReceived(BMessage* message)
const char *newName; const char *newName;
if (message->FindString("name", &newName) != B_OK) { if (message->FindString("name", &newName) != B_OK) {
WRITELOG(("ERROR: Couldn't find name field in update message")); WRITELOG(("ERROR: Couldn't find name field in update "
"message"));
PRINT_OBJECT(*message); PRINT_OBJECT(*message);
break ; break ;
} }
@@ -182,16 +190,17 @@ AutoMounter::MessageReceived(BMessage* message)
// //
dev_t parentDevice; dev_t parentDevice;
if (message->FindInt32("device", &parentDevice) != B_OK) { if (message->FindInt32("device", &parentDevice) != B_OK) {
WRITELOG(("ERROR: Couldn't find 'device' field in update" WRITELOG(("ERROR: Couldn't find 'device' field in "
" message")); "update message"));
PRINT_OBJECT(*message); PRINT_OBJECT(*message);
break; break;
} }
ino_t toDirectory; ino_t toDirectory;
if (message->FindInt64("to directory", &toDirectory)!=B_OK){ if (message->FindInt64("to directory", &toDirectory)
WRITELOG(("ERROR: Couldn't find 'to directory' field in update" != B_OK) {
"message")); WRITELOG(("ERROR: Couldn't find 'to directory' field "
"in update message"));
PRINT_OBJECT(*message); PRINT_OBJECT(*message);
break; break;
} }
@@ -200,19 +209,20 @@ AutoMounter::MessageReceived(BMessage* message)
BNode entryNode(&root_entry); BNode entryNode(&root_entry);
if (entryNode.InitCheck() != B_OK) { if (entryNode.InitCheck() != B_OK) {
WRITELOG(("ERROR: Couldn't create mount point entry node: %s/n", WRITELOG(("ERROR: Couldn't create mount point entry "
strerror(entryNode.InitCheck()))); "node: %s/n", strerror(entryNode.InitCheck())));
break; break;
} }
node_ref mountPointNode; node_ref mountPointNode;
if (entryNode.GetNodeRef(&mountPointNode) != B_OK) { if (entryNode.GetNodeRef(&mountPointNode) != B_OK) {
WRITELOG(("ERROR: Couldn't get node ref for new mount point")); WRITELOG(("ERROR: Couldn't get node ref for new mount "
"point"));
break; break;
} }
WRITELOG(("Attempt to rename device %li to %s", mountPointNode.device, WRITELOG(("Attempt to rename device %li to %s",
newName)); mountPointNode.device, newName));
Partition *partition = FindPartition(mountPointNode.device); Partition *partition = FindPartition(mountPointNode.device);
if (partition != NULL) { if (partition != NULL) {
@@ -227,8 +237,8 @@ AutoMounter::MessageReceived(BMessage* message)
partition->SetVolumeName(newName); partition->SetVolumeName(newName);
break; break;
} else { } else {
WRITELOG(("ERROR: Device %li does not appear to be present", WRITELOG(("ERROR: Device %li does not appear to be "
mountPointNode.device)); "present", mountPointNode.device));
} }
} }
} }
@@ -247,8 +257,8 @@ bool
AutoMounter::QuitRequested() AutoMounter::QuitRequested()
{ {
if (!BootedInSafeMode()) { if (!BootedInSafeMode()) {
// don't write out settings in safe mode - this would overwrite the // Don't write out settings in safe mode - this would overwrite the
// normal, non-safe mode settings // normal, non-safe mode settings.
_WriteSettings(); _WriteSettings();
} }
@@ -328,9 +338,9 @@ AutoMounter::_ScriptReceived(BMessage *message, int32 index,
switch (message->what) { switch (message->what) {
case B_EXECUTE_PROPERTY: case B_EXECUTE_PROPERTY:
if (strcmp("InitialScan", property) == 0) { if (strcmp("InitialScan", property) == 0) {
printf("performing initial scan.\n");
_MountVolumes(fNormalMode, fRemovableMode, true); _MountVolumes(fNormalMode, fRemovableMode, true);
err = reply.AddString("result", "Previous volumes mounted."); err = reply.AddString("result",
B_TRANSLATE("Previous volumes mounted."));
} }
break; break;
} }
@@ -378,24 +388,30 @@ suggest_mount_flags(const BPartition* partition, uint32* _flags)
if (askReadOnly) { if (askReadOnly) {
// Suggest to the user to mount read-only until Haiku is more mature. // Suggest to the user to mount read-only until Haiku is more mature.
BString string; BString string;
string << "Mounting volume "; if (partition->ContentName() != NULL) {
if (partition->ContentName() != NULL) char buffer[512];
string << "'" << partition->ContentName() << "'\n\n"; snprintf(buffer, sizeof(buffer),
else B_TRANSLATE("Mounting volume '%s'\n\n"),
string << "<unnamed volume>\n\n"; partition->ContentName());
string << buffer;
} else
string << B_TRANSLATE("Mounting volume <unnamed volume>\n\n");
// TODO: Use distro name instead of "Haiku"... // TODO: Use distro name instead of "Haiku"...
if (!isBFS) { if (!isBFS) {
string << "The file system on this volume is not the Haiku file " string << B_TRANSLATE("The file system on this volume is not the "
"system. It is strongly suggested to mount it in read-only " "Haiku file system. It is strongly suggested to mount it in "
"mode. "; "read-only mode. This will prevent unintentional data loss "
"because of errors in Haiku.");
} else { } else {
string << "It is suggested to mount all additional Haiku volumes " string << B_TRANSLATE("It is suggested to mount all additional "
"in read-only mode. "; "Haiku volumes in read-only mode. This will prevent "
"unintentional data loss because of errors in Haiku.");
} }
string << "This will prevent unintentional data loss because of "
"errors in Haiku."; BAlert* alert = new BAlert(B_TRANSLATE("Mount warning"),
BAlert* alert = new BAlert("Mount warning", string.String(), string.String(), B_TRANSLATE("Mount read/write"),
"Mount read/write", "Cancel", "Mount read-only", B_TRANSLATE("Cancel"), B_TRANSLATE("Mount read-only"),
B_WIDTH_FROM_WIDEST, B_WARNING_ALERT); B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
alert->SetShortcut(1, B_ESCAPE); alert->SetShortcut(1, B_ESCAPE);
int32 choice = alert->Go(); int32 choice = alert->Go();
@@ -546,9 +562,11 @@ AutoMounter::_MountVolume(const BMessage* message)
status_t status = partition->Mount(NULL, mountFlags); status_t status = partition->Mount(NULL, mountFlags);
if (status < B_OK) { if (status < B_OK) {
BString string; char text[512];
string << "Error mounting volume. (" << strerror(status) << ")"; snprintf(text, sizeof(text),
(new BAlert("", string.String(), "OK"))->Go(NULL); B_TRANSLATE("Error mounting volume:\n\n%s"), strerror(status));
(new BAlert(B_TRANSLATE("Mount error"), text,
B_TRANSLATE("OK")))->Go(NULL);
} }
} }
@@ -556,15 +574,17 @@ AutoMounter::_MountVolume(const BMessage* message)
bool bool
AutoMounter::_SuggestForceUnmount(const char* name, status_t error) AutoMounter::_SuggestForceUnmount(const char* name, status_t error)
{ {
BString text; char text[1024];
text << "Could not unmount disk \"" << name << "\":\n\t"; snprintf(text, sizeof(text),
text << strerror(error); B_TRANSLATE("Could not unmount disk \"%s\":\n\t%s\n\n"
text << "\n\nShould unmounting be forced?\n\n" "Should unmounting be forced?\n\n"
"Note: If an application is currently writing to the volume, " "Note: If an application is currently writing to the volume, "
"unmounting it now might result in loss of data.\n"; "unmounting it now might result in loss of data.\n"),
name, strerror(error));
BAlert* alert = new BAlert("", text.String(), "Cancel", "Force unmount", BAlert* alert = new BAlert(B_TRANSLATE("Force unmount"), text,
NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); B_TRANSLATE("Cancel"), B_TRANSLATE("Force unmount"), NULL,
B_WIDTH_AS_USUAL, B_WARNING_ALERT);
alert->SetShortcut(0, B_ESCAPE); alert->SetShortcut(0, B_ESCAPE);
int32 choice = alert->Go(); int32 choice = alert->Go();
@@ -575,12 +595,12 @@ AutoMounter::_SuggestForceUnmount(const char* name, status_t error)
void void
AutoMounter::_ReportUnmountError(const char* name, status_t error) AutoMounter::_ReportUnmountError(const char* name, status_t error)
{ {
BString text; char text[512];
text << "Could not unmount disk \"" << name << "\":\n\t"; snprintf(text, sizeof(text), B_TRANSLATE("Could not unmount disk "
text << strerror(error); "\"%s\":\n\t%s"), name, strerror(error));
(new BAlert("", text.String(), "OK", NULL, NULL, B_WIDTH_AS_USUAL, (new BAlert(B_TRANSLATE("Unmount error"), text, B_TRANSLATE("OK"),
B_WARNING_ALERT))->Go(NULL); NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT))->Go(NULL);
} }
@@ -903,7 +923,11 @@ AutoMounter::_GetSettings(BMessage *message)
int int
main(int argc, char* argv[]) main(int argc, char* argv[])
{ {
BCatalog appCatalog;
AutoMounter app; AutoMounter app;
be_locale->GetAppCatalog(&appCatalog);
app.Run(); app.Run();
return 0; return 0;
} }
+7 -1
View File
@@ -7,8 +7,14 @@ Server mount_server
AutoMounter.cpp AutoMounter.cpp
# AutoMounterSettings.cpp # AutoMounterSettings.cpp
: :
libbe.so libbe.so liblocale.so
$(TARGET_LIBSTDC++) $(TARGET_LIBSTDC++)
: :
mount_server.rdef mount_server.rdef
; ;
DoCatalogs mount_server :
x-vnd.Haiku-mount_server
:
AutoMounter.cpp
;