Ejemplo n.º 1
0
namespace ipcgenutils
{
#ifdef ENABLE_TRACE_API
  static TraceGuard* s_parent = NULL;

  static char** getSpacesArray(int size)
  {
    char** ret = new char*[size];
    for (int i = 0; i < size; i++)
    {
      ret[i] = new char[i + 1];

      int j;
      for (j = 0; j < i; j++)
        ret[i][j] = ' ';
      ret[i][j] = 0;
    }
    return ret;
  }

  static char** spaces = getSpacesArray(256);

  TraceGuard::TraceGuard(const char* _function) :function(_function) 
  {
    parent = s_parent;
    depth = parent == NULL ? 0 : parent->depth + 1;
    s_parent = this;

    printf("%s TRACE Entering %s\n", spaces[depth], function);
  }

  TraceGuard::~TraceGuard() 
  {
    printf("%s TRACE Leaving %s\n", spaces[depth], function);

    s_parent = parent;
  }
#endif
}
Ejemplo n.º 2
0
namespace XBMCAddonUtils
{
  //***********************************************************
  // Some simple helpers
  void guiLock()
  {
    g_graphicsContext.Lock();
  }

  void guiUnlock()
  {
    g_graphicsContext.Unlock();
  }
  //***********************************************************
  
  static char defaultImage[1024];

  const char *getDefaultImage(char* cControlType, char* cTextureType, char* cDefault)
  {
    // create an xml block so that we can resolve our defaults
    // <control type="type">
    //   <description />
    // </control>
    TiXmlElement control("control");
    control.SetAttribute("type", cControlType);
    TiXmlElement filler("description");
    control.InsertEndChild(filler);
    g_SkinInfo->ResolveIncludes(&control);

    // ok, now check for our texture type
    TiXmlElement *pTexture = control.FirstChildElement(cTextureType);
    if (pTexture)
    {
      // found our textureType
      TiXmlNode *pNode = pTexture->FirstChild();
      if (pNode && pNode->Value()[0] != '-')
      {
        strncpy(defaultImage, pNode->Value(), sizeof(defaultImage));
        defaultImage[sizeof(defaultImage) - 1] = '\0';
        return defaultImage;
      }
    }
    return cDefault;
  }

#ifdef ENABLE_XBMC_TRACE_API
  static XbmcThreads::ThreadLocal<TraceGuard> tlParent;

  static char** getSpacesArray(int size)
  {
    char** ret = new char*[size];
    for (int i = 0; i < size; i++)
    {
      ret[i] = new char[i + 1];

      int j;
      for (j = 0; j < i; j++)
        ret[i][j] = ' ';
      ret[i][j] = 0;
    }
    return ret;
  }

  static char** spaces = getSpacesArray(256);

  const char* TraceGuard::getSpaces() { return spaces[depth]; }

  TraceGuard::TraceGuard(const char* _function) :function(_function) 
  {
    parent = tlParent.get();
    depth = parent == NULL ? 0 : parent->depth + 1;

    tlParent.set(this);

    CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function); 
  }

  TraceGuard::TraceGuard() :function(NULL) 
  {
    parent = tlParent.get();
    depth = parent == NULL ? 0 : parent->depth + 1;
    tlParent.set(this);
    // silent
  }

  TraceGuard::~TraceGuard() 
  {
    if (function)
      CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);

    // need to pop the stack
    tlParent.set(this->parent);
  }
#endif


}
Ejemplo n.º 3
0
namespace XBMCAddonUtils
{
  GuiLock::GuiLock(XBMCAddon::LanguageHook* languageHook, bool offScreen)
    : m_languageHook(languageHook), m_offScreen(offScreen)
  {
    if (!m_languageHook)
      m_languageHook = XBMCAddon::LanguageHook::GetLanguageHook();
    if (m_languageHook)
      m_languageHook->DelayedCallOpen();

    if (!m_offScreen)
      g_application.LockFrameMoveGuard();
  }

  GuiLock::~GuiLock()
  {
    if (!m_offScreen)
      g_application.UnlockFrameMoveGuard();

    if (m_languageHook)
      m_languageHook->DelayedCallClose();
  }

  static char defaultImage[1024];

  const char *getDefaultImage(char* cControlType, char* cTextureType)
  {
    // create an xml block so that we can resolve our defaults
    // <control type="type">
    //   <description />
    // </control>
    TiXmlElement control("control");
    control.SetAttribute("type", cControlType);
    TiXmlElement filler("description");
    control.InsertEndChild(filler);
    g_SkinInfo->ResolveIncludes(&control);

    // ok, now check for our texture type
    TiXmlElement *pTexture = control.FirstChildElement(cTextureType);
    if (pTexture)
    {
      // found our textureType
      TiXmlNode *pNode = pTexture->FirstChild();
      if (pNode && pNode->Value()[0] != '-')
      {
        strncpy(defaultImage, pNode->Value(), sizeof(defaultImage));
        defaultImage[sizeof(defaultImage) - 1] = '\0';
        return defaultImage;
      }
    }
    return "";
  }

#ifdef ENABLE_XBMC_TRACE_API
  static thread_local TraceGuard* tlParent;

  static char** getSpacesArray(int size)
  {
    char** ret = new char*[size];
    for (int i = 0; i < size; i++)
    {
      ret[i] = new char[i + 1];

      int j;
      for (j = 0; j < i; j++)
        ret[i][j] = ' ';
      ret[i][j] = 0;
    }
    return ret;
  }

  static char** spaces = getSpacesArray(256);

  const char* TraceGuard::getSpaces() { return spaces[depth]; }

  TraceGuard::TraceGuard(const char* _function) :function(_function)
  {
    parent = tlParent;
    depth = parent == NULL ? 0 : parent->depth + 1;

    tlParent = this;

    CLog::Log(LOGDEBUG, "%sNEWADDON Entering %s", spaces[depth], function);
  }

  TraceGuard::TraceGuard() :function(NULL)
  {
    parent = tlParent;
    depth = parent == NULL ? 0 : parent->depth + 1;
    tlParent = this;
    // silent
  }

  TraceGuard::~TraceGuard()
  {
    if (function)
      CLog::Log(LOGDEBUG, "%sNEWADDON Leaving %s", spaces[depth], function);

    // need to pop the stack
    tlParent = this->parent;
  }
#endif


}