2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
23 #include "AddonUtils.h"
24 #include "guilib/GraphicContext.h"
25 #include "utils/XBMCTinyXML.h"
26 #include "addons/Skin.h"
27 #include "utils/log.h"
28 #include "threads/ThreadLocal.h"
30 namespace XBMCAddonUtils
32 //***********************************************************
33 // Some simple helpers
36 g_graphicsContext.Lock();
41 g_graphicsContext.Unlock();
43 //***********************************************************
45 static char defaultImage[1024];
47 const char *getDefaultImage(char* cControlType, char* cTextureType, char* cDefault)
49 // create an xml block so that we can resolve our defaults
50 // <control type="type">
53 TiXmlElement control("control");
54 control.SetAttribute("type", cControlType);
55 TiXmlElement filler("description");
56 control.InsertEndChild(filler);
57 g_SkinInfo->ResolveIncludes(&control);
59 // ok, now check for our texture type
60 TiXmlElement *pTexture = control.FirstChildElement(cTextureType);
63 // found our textureType
64 TiXmlNode *pNode = pTexture->FirstChild();
65 if (pNode && pNode->Value()[0] != '-')
67 strncpy(defaultImage, pNode->Value(), sizeof(defaultImage));
68 defaultImage[sizeof(defaultImage) - 1] = '\0';
75 #ifdef ENABLE_TRACE_API
76 static XbmcThreads::ThreadLocal<TraceGuard> tlParent;
78 static char** getSpacesArray(int size)
80 char** ret = new char*[size];
81 for (int i = 0; i < size; i++)
83 ret[i] = new char[i + 1];
86 for (j = 0; j < i; j++)
93 static char** spaces = getSpacesArray(256);
95 const char* TraceGuard::getSpaces() { return spaces[depth]; }
97 TraceGuard::TraceGuard(const char* _function) :function(_function)
99 parent = tlParent.get();
100 depth = parent == NULL ? 0 : parent->depth + 1;
104 CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function);
107 TraceGuard::TraceGuard() :function(NULL)
109 parent = tlParent.get();
110 depth = parent == NULL ? 0 : parent->depth + 1;
115 TraceGuard::~TraceGuard()
118 CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);
120 // need to pop the stack
121 tlParent.set(this->parent);