From 77d2abe296cba1de16ae16bdaf53300b44efde08 Mon Sep 17 00:00:00 2001 From: stippi Date: Mon, 15 Feb 2010 14:06:28 +0000 Subject: [PATCH] First structure of BrowsingHistory. Does nothing, but can in theory save settings. git-svn-id: http://svn.haiku-os.org/webpositive/webkit/trunk@91 94f232f2-1747-11df-bad5-a5bfde151594 --- src/apps/webpositive/BrowsingHistory.cpp | 83 ++++++++++++++++++++++++ src/apps/webpositive/BrowsingHistory.h | 51 +++++++++++++++ 2 files changed, 134 insertions(+) create mode 100644 src/apps/webpositive/BrowsingHistory.cpp create mode 100644 src/apps/webpositive/BrowsingHistory.h diff --git a/src/apps/webpositive/BrowsingHistory.cpp b/src/apps/webpositive/BrowsingHistory.cpp new file mode 100644 index 0000000000..e70d3c0e03 --- /dev/null +++ b/src/apps/webpositive/BrowsingHistory.cpp @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2010 Stephan Aßmus + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "BrowsingHistory.h" + +#include +#include +#include +#include +#include +#include + + +BrowsingHistory BrowsingHistory::s_defaultInstance; + +BrowsingHistory::BrowsingHistory() + : BLocker("browsing history") +{ + BFile settingsFile; + if (openSettingsFile(settingsFile, B_READ_ONLY)) { + BMessage settingsArchive; + settingsArchive.Unflatten(&settingsFile); + // TODO: ... + } +} + +BrowsingHistory::~BrowsingHistory() +{ + saveSettings(); +} + +/*static*/ BrowsingHistory* BrowsingHistory::defaultInstance() +{ + return &s_defaultInstance; +} + +// #pragma mark - private + +void BrowsingHistory::saveSettings() +{ + BFile settingsFile; + if (openSettingsFile(settingsFile, B_CREATE_FILE | B_ERASE_FILE | B_WRITE_ONLY)) { + BMessage settingsArchive; + // TODO: ... + settingsArchive.Flatten(&settingsFile); + } +} + +bool BrowsingHistory::openSettingsFile(BFile& file, uint32 mode) +{ + BPath path; + if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK + || path.Append("HaikuLauncher_BrowsingHistory") != B_OK) { + return false; + } + return file.SetTo(path.Path(), mode) == B_OK; +} + diff --git a/src/apps/webpositive/BrowsingHistory.h b/src/apps/webpositive/BrowsingHistory.h new file mode 100644 index 0000000000..82ef0ba04f --- /dev/null +++ b/src/apps/webpositive/BrowsingHistory.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2010 Stephan Aßmus + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef BrowsingHistory_h +#define BrowsingHistory_h + +#include + +class BFile; + +class BrowsingHistory : public BLocker { +public: + static BrowsingHistory* defaultInstance(); + +private: + BrowsingHistory(); + virtual ~BrowsingHistory(); + + void saveSettings(); + bool openSettingsFile(BFile& file, uint32 mode); + +private: + static BrowsingHistory s_defaultInstance; +}; + +#endif // BrowsingHistory_h +