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.

updatablesetting.cpp 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* -*- Mode: c++; tab-width: 4; c-basic-offset: 4 -*-
  2. *
  3. * Copyright (C) 1995-2007 Opera Software AS. All rights reserved.
  4. *
  5. * This file is part of the Opera web browser.
  6. * It may not be distributed under any circumstances.
  7. */
  8. /** \file
  9. * This file contains the implementation for UpdatableResource with
  10. * subclasses.
  11. * @author Marius Blomli mariusab@opera.com
  12. */
  13. #include "core/pch.h"
  14. #ifdef AUTO_UPDATE_SUPPORT
  15. #include "adjunct/autoupdate/updatablesetting.h"
  16. #include "modules/prefs/prefsmanager/prefsmanager.h"
  17. #include "adjunct/desktop_util/resources/ResourceUtils.h"
  18. ////////////////////////////////////////////////////////////////////////////////////////////////
  19. ////////////////////////////////////////////////////////////////////////////////////////////////
  20. /// ///
  21. /// UpdatableSetting ///
  22. /// ///
  23. ////////////////////////////////////////////////////////////////////////////////////////////////
  24. ////////////////////////////////////////////////////////////////////////////////////////////////
  25. UpdatableSetting::UpdatableSetting()
  26. {
  27. }
  28. OP_STATUS UpdatableSetting::UpdateResource()
  29. {
  30. OpString8 key8, section8;
  31. OpString key, section, data;
  32. RETURN_IF_ERROR(GetAttrValue(URA_SECTION, section));
  33. RETURN_IF_ERROR(GetAttrValue(URA_KEY, key));
  34. RETURN_IF_ERROR(GetAttrValue(URA_DATA, data));
  35. if (section == "Auto Update" && key == "Country Code")
  36. {
  37. if (data == "A6")
  38. {
  39. // A6 means "Unknown Country" - see discussion in BINT-76
  40. data.Empty();
  41. }
  42. if (data.HasContent())
  43. {
  44. // Save received Country Code. At the next upgrade Opera will inspect the list of saved
  45. // country codes and may decide to switch region used when selecting default customization
  46. // files (bookmarks, speed dials, etc.) - see DSK-344623.
  47. // AddAuCountry must be called even if received country code is the same as
  48. // current value of the pref, so calling it here insted of from PrefChanged (DSK-366548).
  49. OpStatus::Ignore(ResourceUtils::AddAuCountry(data));
  50. }
  51. }
  52. RETURN_IF_ERROR(section8.Set(section.CStr()));
  53. RETURN_IF_ERROR(key8.Set(key.CStr()));
  54. BOOL ok;
  55. OpString oldvalue;
  56. TRAPD(err, ok = g_prefsManager->GetPreferenceL(section8.CStr(), key8.CStr(), oldvalue));
  57. if(OpStatus::IsSuccess(err) && ok)
  58. {
  59. if(oldvalue.Compare(data) == 0)
  60. {
  61. // Preference not changed
  62. return OpStatus::OK;
  63. }
  64. }
  65. TRAP(err, ok = g_prefsManager->WritePreferenceL(section8.CStr(), key8.CStr(), data));
  66. if(OpStatus::IsError(err))
  67. return err;
  68. TRAP(err, g_prefsManager->CommitL());
  69. if(ok)
  70. return OpStatus::OK;
  71. else
  72. return OpStatus::ERR;
  73. }
  74. BOOL UpdatableSetting::IsUpdateCheckInterval()
  75. {
  76. OpString section, key;
  77. RETURN_VALUE_IF_ERROR(GetAttrValue(URA_SECTION, section), FALSE);
  78. RETURN_VALUE_IF_ERROR(GetAttrValue(URA_KEY, key), FALSE);
  79. if (section.IsEmpty() || key.IsEmpty())
  80. return FALSE;
  81. if(section.CompareI("Auto Update") == 0 && key.CompareI("Update Check Interval") == 0)
  82. return TRUE;
  83. return FALSE;
  84. }
  85. BOOL UpdatableSetting::VerifyAttributes()
  86. {
  87. return HasAttrWithContent(URA_FILE) && HasAttrWithContent(URA_SECTION) && HasAttrWithContent(URA_KEY);
  88. }
  89. ////////////////////////////////////////////////////////////////////////////////////////////////
  90. #endif // AUTO_UPDATE_SUPPORT