summaryrefslogtreecommitdiffstats
path: root/comm/suite/components/migration/src/nsSuiteProfileMigratorUtils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'comm/suite/components/migration/src/nsSuiteProfileMigratorUtils.cpp')
-rw-r--r--comm/suite/components/migration/src/nsSuiteProfileMigratorUtils.cpp66
1 files changed, 66 insertions, 0 deletions
diff --git a/comm/suite/components/migration/src/nsSuiteProfileMigratorUtils.cpp b/comm/suite/components/migration/src/nsSuiteProfileMigratorUtils.cpp
new file mode 100644
index 0000000000..091a96540d
--- /dev/null
+++ b/comm/suite/components/migration/src/nsSuiteProfileMigratorUtils.cpp
@@ -0,0 +1,66 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "nsSuiteProfileMigratorUtils.h"
+#include "nsIPrefBranch.h"
+#include "nsIFile.h"
+#include "nsIInputStream.h"
+#include "nsILineInputStream.h"
+#include "nsIProfileMigrator.h"
+
+#include "nsIURI.h"
+#include "nsNetUtil.h"
+#include "nsIProperties.h"
+#include "nsServiceManagerUtils.h"
+#include "nsISupportsPrimitives.h"
+
+#include "nsAppDirectoryServiceDefs.h"
+#include "nsIStringBundle.h"
+#include "nsCRT.h"
+
+#define MIGRATION_BUNDLE "chrome://communicator/migration/locale/migration.properties"
+
+using namespace mozilla;
+
+void GetMigrateDataFromArray(MigrationData* aDataArray,
+ int32_t aDataArrayLength,
+ bool aReplace, nsIFile* aSourceProfile,
+ uint16_t* aResult)
+{
+ nsCOMPtr<nsIFile> sourceFile;
+ bool exists;
+ MigrationData* cursor;
+ MigrationData* end = aDataArray + aDataArrayLength;
+ for (cursor = aDataArray; cursor < end; ++cursor) {
+ // When in replace mode, all items can be imported.
+ // When in non-replace mode, only items that do not require file
+ // replacement can be imported.
+ if (aReplace || !cursor->replaceOnly) {
+ aSourceProfile->Clone(getter_AddRefs(sourceFile));
+ sourceFile->AppendNative(nsDependentCString(cursor->fileName));
+ sourceFile->Exists(&exists);
+ if (exists)
+ *aResult |= cursor->sourceFlag;
+ }
+ }
+}
+
+void
+GetProfilePath(nsIProfileStartup* aStartup, nsIFile** aProfileDir)
+{
+ *aProfileDir = nullptr;
+
+ if (aStartup) {
+ aStartup->GetDirectory(aProfileDir);
+ }
+ else {
+ nsCOMPtr<nsIProperties> dirSvc
+ (do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID));
+ if (dirSvc) {
+ dirSvc->Get(NS_APP_USER_PROFILE_50_DIR, NS_GET_IID(nsIFile),
+ (void**)aProfileDir);
+ }
+ }
+}