summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2011-07-06 03:49:12 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2011-07-06 03:49:12 +0800
commitfd270518a3989951288428af6a9386edd842d330 (patch)
tree86bb5792f44f659cf57ff827289ce1d4f8952028 /src
parent93d8c3835435f920615219c5481937312bc4dad8 (diff)
downloadmobilebling-fd270518a3989951288428af6a9386edd842d330.tar.gz
mobilebling-fd270518a3989951288428af6a9386edd842d330.tar.bz2
Add missing files
Diffstat (limited to 'src')
-rw-r--r--src/logmessage.cpp85
-rw-r--r--src/valueholder.cpp110
-rw-r--r--src/valueholder.h41
3 files changed, 236 insertions, 0 deletions
diff --git a/src/logmessage.cpp b/src/logmessage.cpp
new file mode 100644
index 0000000..9087455
--- /dev/null
+++ b/src/logmessage.cpp
@@ -0,0 +1,85 @@
+/*
+ * Copyright © 2005 Novell, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Novell, Inc. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Novell, Inc. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECI<<<<<fAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: David Reveman <davidr@novell.com>
+ */
+
+#include <compiz.h>
+#include <cstdio>
+
+const char *
+logLevelToString (CompLogLevel level)
+{
+ switch (level) {
+ case CompLogLevelFatal:
+ return "Fatal";
+ case CompLogLevelError:
+ return "Error";
+ case CompLogLevelWarn:
+ return "Warn";
+ case CompLogLevelInfo:
+ return "Info";
+ case CompLogLevelDebug:
+ return "Debug";
+ default:
+ break;
+ }
+
+ return "Unknown";
+}
+
+void
+logMessage (const char *componentName,
+ CompLogLevel level,
+ const char *message)
+{
+ if (!debugOutput && level >= CompLogLevelDebug)
+ return;
+
+ fprintf (stderr, "%s (%s) - %s: %s\n",
+ programName, componentName,
+ logLevelToString (level), message);
+}
+
+void
+compLogMessage (const char *componentName,
+ CompLogLevel level,
+ const char *format,
+ ...)
+{
+ va_list args;
+ char message[2048];
+
+ va_start (args, format);
+
+ vsnprintf (message, 2048, format, args);
+
+ /* FIXME: That's wrong */
+#if 0
+ if (screen)
+ screen->logMessage (componentName, level, message);
+ else
+#endif
+ logMessage (componentName, level, message);
+
+ va_end (args);
+}
diff --git a/src/valueholder.cpp b/src/valueholder.cpp
new file mode 100644
index 0000000..14405b4
--- /dev/null
+++ b/src/valueholder.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright © 2010 Canonical Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Canonical Ltd. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Canonical Ltd. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
+ */
+
+#include <core/valueholder.h>
+#include <map>
+
+namespace
+{
+ static ValueHolder *gDefault;
+}
+
+class PrivateValueHolder
+{
+ public:
+
+ std::map<CompString, CompPrivate> valueMap;
+};
+
+ValueHolder::ValueHolder () :
+ priv (new PrivateValueHolder)
+{
+}
+
+ValueHolder *
+ValueHolder::Default ()
+{
+ return gDefault;
+}
+
+void
+ValueHolder::SetDefault (ValueHolder *v)
+{
+ gDefault = v;
+}
+
+void
+ValueHolder::storeValue (CompString key, CompPrivate value)
+{
+ std::map<CompString,CompPrivate>::iterator it;
+
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ it->second = value;
+ }
+ else
+ {
+ priv->valueMap.insert (std::pair<CompString,CompPrivate> (key, value));
+ }
+}
+
+void
+ValueHolder::eraseValue (CompString key)
+{
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ priv->valueMap.erase (key);
+ }
+}
+
+bool
+ValueHolder::hasValue (CompString key)
+{
+ return (priv->valueMap.find (key) != priv->valueMap.end ());
+}
+
+CompPrivate
+ValueHolder::getValue (CompString key)
+{
+ CompPrivate p;
+
+ std::map<CompString,CompPrivate>::iterator it;
+ it = priv->valueMap.find (key);
+
+ if (it != priv->valueMap.end ())
+ {
+ return it->second;
+ }
+ else
+ {
+ p.uval = 0;
+ return p;
+ }
+}
diff --git a/src/valueholder.h b/src/valueholder.h
new file mode 100644
index 0000000..e50a6da
--- /dev/null
+++ b/src/valueholder.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright © 2010 Canonical Ltd.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software
+ * and its documentation for any purpose is hereby granted without
+ * fee, provided that the above copyright notice appear in all copies
+ * and that both that copyright notice and this permission notice
+ * appear in supporting documentation, and that the name of
+ * Canonical Ltd. not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Canonical Ltd. makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
+ */
+
+class PrivateValueHolder;
+
+class ValueHolder
+{
+ public:
+
+ ValueHolder ();
+
+ void hasValue (CompString key);
+ void storeValue (CompString key, CompPrivate value);
+ CompPrivate getValue (CompString key);
+
+ private:
+
+ PrivateValueHolder *priv;
+};