Opera 12.15 Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

scope_desktop_utils.cpp 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* -*- Mode: c++; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*-
  2. **
  3. ** Copyright (C) 2010 Opera Software AS. All rights reserved.
  4. **
  5. ** This file is part of the Opera web browser. It may not be distributed
  6. ** under any circumstances.
  7. */
  8. #include "core/pch.h"
  9. #include "modules/scope/src/scope_transport.h"
  10. #include "adjunct/desktop_scope/src/scope_desktop_utils.h"
  11. #include "adjunct/desktop_pi/DesktopOpSystemInfo.h"
  12. #include "modules/locale/oplanguagemanager.h"
  13. #include "modules/locale/locale-enum.h"
  14. /* OpScopeDesktopUtils */
  15. OpScopeDesktopUtils::OpScopeDesktopUtils()
  16. {
  17. }
  18. /* virtual */
  19. OpScopeDesktopUtils::~OpScopeDesktopUtils()
  20. {
  21. }
  22. OP_STATUS OpScopeDesktopUtils::DoGetString(const DesktopStringID &in, DesktopStringText &out)
  23. {
  24. // Calculate the enum using the hash
  25. int enum_value = Str::LocaleString(in.GetEnumText().CStr());
  26. OpString text_string;
  27. g_languageManager->GetString((Str::LocaleString)enum_value, text_string);
  28. if (text_string.IsEmpty())
  29. return SetCommandError(OpScopeTPHeader::InternalError, UNI_L("String not found"));
  30. RETURN_IF_ERROR(out.SetText(text_string.CStr()));
  31. return OpStatus::OK;
  32. }
  33. OP_STATUS OpScopeDesktopUtils::DoGetOperaPath(DesktopPath &out)
  34. {
  35. OpString exec_path;
  36. if (OpStatus::IsError(g_op_system_info->GetBinaryPath(&exec_path)) || exec_path.IsEmpty())
  37. return SetCommandError(OpScopeTPHeader::InternalError, UNI_L("Exec path not found"));
  38. RETURN_IF_ERROR(out.SetPath(exec_path.CStr()));
  39. return OpStatus::OK;
  40. }
  41. OP_STATUS OpScopeDesktopUtils::DoGetLargePreferencesPath(DesktopPath &out)
  42. {
  43. OpString home_path;
  44. RETURN_IF_ERROR(g_folder_manager->GetFolderPath(OPFILE_LOCAL_HOME_FOLDER, home_path));
  45. return out.SetPath(home_path.CStr());
  46. }
  47. OP_STATUS OpScopeDesktopUtils::DoGetSmallPreferencesPath(DesktopPath &out)
  48. {
  49. OpString home_path;
  50. RETURN_IF_ERROR(g_folder_manager->GetFolderPath(OPFILE_HOME_FOLDER, home_path));
  51. return out.SetPath(home_path.CStr());
  52. }
  53. OP_STATUS OpScopeDesktopUtils::DoGetCachePreferencesPath(DesktopPath &out)
  54. {
  55. OpString home_path;
  56. RETURN_IF_ERROR(g_folder_manager->GetFolderPath(OPFILE_CACHE_HOME_FOLDER, home_path));
  57. return out.SetPath(home_path.CStr());
  58. }
  59. OP_STATUS OpScopeDesktopUtils::DoGetCurrentProcessId(DesktopPid &out)
  60. {
  61. out.SetPid(g_op_system_info->GetCurrentProcessId());
  62. return OpStatus::OK;
  63. }