summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@opencompositing.org>2008-08-20 15:40:15 +0200
committerDennis kasprzyk <onestone@opencompositing.org>2008-08-20 15:40:15 +0200
commit682b0c5129f0fd88d259ca6f30e8ed469dc9a162 (patch)
tree21a1850a82b4191387dd4908299f09a2730b74ee /src/main.cpp
parentf4d3ba5048fd23ea455f8d50a81fca586bbc6197 (diff)
downloadunity-window-decorator-682b0c5129f0fd88d259ca6f30e8ed469dc9a162.tar.gz
unity-window-decorator-682b0c5129f0fd88d259ca6f30e8ed469dc9a162.tar.bz2
C++ port of CompMetadata.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp62
1 files changed, 26 insertions, 36 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 8f06e24..7f6e5c5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -69,7 +69,7 @@ Bool onlyCurrentScreen = FALSE;
Bool useCow = TRUE;
#endif
-CompMetadata coreMetadata;
+CompMetadata *coreMetadata = NULL;
static void
usage (void)
@@ -122,10 +122,10 @@ signalHandler (int sig)
}
typedef struct _CompIOCtx {
- int offset;
- char *pluginData;
- char *textureFilterData;
- char *refreshRateData;
+ unsigned int offset;
+ char *pluginData;
+ char *textureFilterData;
+ char *refreshRateData;
} CompIOCtx;
static int
@@ -133,15 +133,16 @@ readCoreXmlCallback (void *context,
char *buffer,
int length)
{
- CompIOCtx *ctx = (CompIOCtx *) context;
- int offset = ctx->offset;
- int i, j;
+ CompIOCtx *ctx = (CompIOCtx *) context;
+ unsigned int offset = ctx->offset;
+ unsigned int i, j;
- i = compReadXmlChunk ("<compiz><core><display>", &offset, buffer, length);
+ i = CompMetadata::readXmlChunk ("<compiz><core><display>", &offset, buffer,
+ length);
for (j = 0; j < COMP_DISPLAY_OPTION_NUM; j++)
{
- CompMetadataOptionInfo info = coreDisplayOptionInfo[j];
+ CompMetadata::OptionInfo info = coreDisplayOptionInfo[j];
switch (j) {
case COMP_DISPLAY_OPTION_ACTIVE_PLUGINS:
@@ -155,18 +156,16 @@ readCoreXmlCallback (void *context,
break;
}
- i += compReadXmlChunkFromMetadataOptionInfo (&info,
- &offset,
- buffer + i,
- length - i);
+ i += CompMetadata::readXmlChunkFromOptionInfo (&info, &offset,
+ buffer + i, length - i);
}
- i += compReadXmlChunk ("</display><screen>", &offset,
- buffer + i, length - 1);
+ i += CompMetadata::readXmlChunk ("</display><screen>", &offset,
+ buffer + i, length - 1);
for (j = 0; j < COMP_SCREEN_OPTION_NUM; j++)
{
- CompMetadataOptionInfo info = coreScreenOptionInfo[j];
+ CompMetadata::OptionInfo info = coreScreenOptionInfo[j];
switch (j) {
case COMP_SCREEN_OPTION_REFRESH_RATE:
@@ -176,16 +175,14 @@ readCoreXmlCallback (void *context,
break;
}
- i += compReadXmlChunkFromMetadataOptionInfo (&info,
- &offset,
- buffer + i,
- length - i);
+ i += CompMetadata::readXmlChunkFromOptionInfo (&info, &offset,
+ buffer + i, length - i);
}
- i += compReadXmlChunk ("</screen></core></compiz>", &offset, buffer + i,
- length - i);
+ i += CompMetadata::readXmlChunk ("</screen></core></compiz>", &offset,
+ buffer + i, length - i);
- if (!offset && length > i)
+ if (!offset && length > (int)i)
buffer[i++] = '\0';
ctx->offset += i;
@@ -354,16 +351,9 @@ main (int argc, char **argv)
LIBXML_TEST_VERSION;
- if (!compInitMetadata (&coreMetadata))
- {
- compLogMessage (NULL, "core", CompLogLevelFatal,
- "Couldn't initialize core metadata");
- return 1;
- }
+ coreMetadata = new CompMetadata ();
- if (!compAddMetadataFromIO (&coreMetadata,
- readCoreXmlCallback, NULL,
- &ctx))
+ if (!coreMetadata->addFromIO (readCoreXmlCallback, NULL, &ctx))
return 1;
if (ctx.refreshRateData)
@@ -372,13 +362,13 @@ main (int argc, char **argv)
if (ctx.pluginData)
free (ctx.pluginData);
- compAddMetadataFromFile (&coreMetadata, "core");
+ coreMetadata->addFromFile ("core");
core = new CompCore();
if (!core)
return 1;
-
+
if (!core->init ())
return 1;
@@ -394,7 +384,7 @@ main (int argc, char **argv)
closeSession ();
delete core;
- compFiniMetadata (&coreMetadata);
+ delete coreMetadata;
xmlCleanupParser ();