Skip to content

Commit

Permalink
Moved the OnAction handling for Show_Internal to the mixin. Added the…
Browse files Browse the repository at this point in the history
… OnDeinitWindow to the WindowXML class. changed a few upcalls to skip the interceptor.
  • Loading branch information
Jim Carroll committed Sep 18, 2012
1 parent ba3b60f commit b4f3914
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 78 deletions.
2 changes: 1 addition & 1 deletion xbmc/interfaces/legacy/AddonUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#pragma once

//#define ENABLE_TRACE_API
#define ENABLE_TRACE_API

#include "threads/SingleLock.h"

Expand Down
8 changes: 7 additions & 1 deletion xbmc/interfaces/legacy/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

#define ACTIVE_WINDOW g_windowManager.GetActiveWindow()

#define A(x) interceptor->x

namespace XBMCAddon
{
namespace xbmcgui
Expand Down Expand Up @@ -342,7 +344,7 @@ namespace XBMCAddon
void Window::WaitForActionEvent()
{
TRACE;
DelayedCallGuard dcguard(languageHook);
// DO NOT MAKE THIS A DELAYED CALL!!!!
if (languageHook)
languageHook->waitForEvent(m_actionEvent);
m_actionEvent.Reset();
Expand All @@ -369,6 +371,7 @@ namespace XBMCAddon

bool Window::OnBack(int actionID)
{
// we are always a Python window ... keep that in mind when reviewing the old code
return true;
}

Expand Down Expand Up @@ -634,6 +637,9 @@ namespace XBMCAddon
// Window_Close(self, NULL);
// break;
// }
{
DelayedCallGuard dcguard(languageHook); // MakePendingCalls
}
WaitForActionEvent();
}
}
Expand Down
31 changes: 4 additions & 27 deletions xbmc/interfaces/legacy/WindowDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ namespace XBMCAddon

bool WindowDialog::OnMessage(CGUIMessage& message)
{
#ifdef ENABLE_TRACE_API
TRACE;
CLog::Log(LOGDEBUG,"NEWADDON WindowDialog::OnMessage Message %d", message.GetMessage());
CLog::Log(LOGDEBUG,"%sNEWADDON WindowDialog::OnMessage Message %d", _tg.getSpaces(),message.GetMessage());
#endif

switch(message.GetMessage())
{
Expand All @@ -66,32 +68,7 @@ namespace XBMCAddon
bool WindowDialog::OnAction(const CAction &action)
{
TRACE;

switch (action.GetID())
{
case HACK_CUSTOM_ACTION_OPENING:
{
// This is from the CGUIPythonWindowXMLDialog::Show_Internal
g_windowManager.RouteToWindow(ref(window).get());
// active this dialog...
CGUIMessage msg(GUI_MSG_WINDOW_INIT,0,0);
OnMessage(msg);
// TODO: Figure out how to clean up the CAction
return true;
}
break;

case HACK_CUSTOM_ACTION_CLOSING:
{
// This is from the CGUIPythonWindowXMLDialog::Show_Internal
close();
// TODO: Figure out how to clean up the CAction
return true;
}
break;
}

return Window::OnAction(action);
return WindowDialogMixin::OnAction(action) ? true : Window::OnAction(action);
}

void WindowDialog::OnDeinitWindow(int nextWindowID)
Expand Down
36 changes: 32 additions & 4 deletions xbmc/interfaces/legacy/WindowDialogMixin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "WindowInterceptor.h"

#include "ApplicationMessenger.h"
#include "guilib/GUIWindowManager.h"

namespace XBMCAddon
{
Expand All @@ -31,8 +32,6 @@ namespace XBMCAddon
void WindowDialogMixin::show()
{
TRACE;
DelayedCallGuard dcguard(w->languageHook);

ThreadMessage tMsg = {TMSG_GUI_PYTHON_DIALOG, HACK_CUSTOM_ACTION_OPENING, 0};
tMsg.lpVoid = w->window->get();
CApplicationMessenger::Get().SendMessage(tMsg, true);
Expand All @@ -41,18 +40,47 @@ namespace XBMCAddon
void WindowDialogMixin::close()
{
TRACE;
DelayedCallGuard dcguard(w->languageHook);
w->bModal = false;
w->PulseActionEvent();

ThreadMessage tMsg = {TMSG_GUI_PYTHON_DIALOG, HACK_CUSTOM_ACTION_CLOSING, 0};
tMsg.lpVoid = w->window->get();
CApplicationMessenger::Get().SendMessage(tMsg, true);

w->iOldWindowId = 0;
}

bool WindowDialogMixin::IsDialogRunning() const { return w->window->isActive(); }
bool WindowDialogMixin::IsDialogRunning() const { TRACE; return w->window->isActive(); }

bool WindowDialogMixin::OnAction(const CAction &action)
{
TRACE;
switch (action.GetID())
{
case HACK_CUSTOM_ACTION_OPENING:
{
// This is from the CGUIPythonWindowXMLDialog::Show_Internal
g_windowManager.RouteToWindow(w->window->get());
// active this dialog...
CGUIMessage msg(GUI_MSG_WINDOW_INIT,0,0);
w->OnMessage(msg);
w->window->setActive(true);
// TODO: Figure out how to clean up the CAction
return true;
}
break;

case HACK_CUSTOM_ACTION_CLOSING:
{
// This is from the CGUIPythonWindowXMLDialog::Show_Internal
w->window->get()->Close();
return true;
}
break;
}

return false;
}
}
}

Expand Down
1 change: 1 addition & 0 deletions xbmc/interfaces/legacy/WindowDialogMixin.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace XBMCAddon

#ifndef SWIG
SWIGHIDDENVIRTUAL bool IsDialogRunning() const;
SWIGHIDDENVIRTUAL bool OnAction(const CAction &action);
#endif
};
}
Expand Down
27 changes: 16 additions & 11 deletions xbmc/interfaces/legacy/WindowInterceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ namespace XBMCAddon
Window* _window, int windowid) : P(windowid, "")
{
((classname = "Interceptor<") += specializedName) += ">";
CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE constructing %s 0x%lx", classname.c_str(), (long)(((void*)this)));
#ifdef ENABLE_TRACE_API
XBMCAddonUtils::TraceGuard tg;
CLog::Log(LOGDEBUG, "%sNEWADDON constructing %s 0x%lx", tg.getSpaces(),classname.c_str(), (long)(((void*)this)));
#endif
window = _window;
P::SetLoadType(CGUIWindow::LOAD_ON_GUI_INIT);
}
Expand All @@ -139,14 +142,20 @@ namespace XBMCAddon
const char* xmlfile) : P(windowid, xmlfile)
{
((classname = "Interceptor<") += specializedName) += ">";
CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE constructing %s 0x%lx", classname.c_str(), (long)(((void*)this)));
#ifdef ENABLE_TRACE_API
XBMCAddonUtils::TraceGuard tg;
CLog::Log(LOGDEBUG, "%sNEWADDON constructing %s 0x%lx", tg.getSpaces(),classname.c_str(), (long)(((void*)this)));
#endif
window = _window;
P::SetLoadType(CGUIWindow::LOAD_ON_GUI_INIT);
}

virtual ~Interceptor()
{
CLog::Log(LOGDEBUG, "NEWADDON LIFECYCLE destroying %s 0x%lx", classname.c_str(), (long)(((void*)this)));
#ifdef ENABLE_TRACE_API
XBMCAddonUtils::TraceGuard tg;
CLog::Log(LOGDEBUG, "%sNEWADDON LIFECYCLE destroying %s 0x%lx", tg.getSpaces(),classname.c_str(), (long)(((void*)this)));
#endif
}

virtual bool OnMessage(CGUIMessage& message)
Expand All @@ -165,14 +174,14 @@ namespace XBMCAddon

virtual bool IsDialogRunning() const { TRACE; return checkedb(IsDialogRunning()); };
virtual bool IsDialog() const { TRACE; return checkedb(IsDialog()); };
virtual bool IsMediaWindow() const { return checkedb(IsMediaWindow());; };
virtual bool IsMediaWindow() const { TRACE; return checkedb(IsMediaWindow());; };

virtual void setActive(bool active) { P::m_active = active; }
virtual bool isActive() { return P::m_active; }
virtual void setActive(bool active) { TRACE; P::m_active = active; }
virtual bool isActive() { TRACE; return P::m_active; }
};

template <class P /* extends CGUIWindow*/> class InterceptorDialog :
public Interceptor<P> //, public DialogMixin
public Interceptor<P>
{
public:
InterceptorDialog(const char* specializedName,
Expand All @@ -185,10 +194,6 @@ namespace XBMCAddon
const char* xmlfile) :
Interceptor<P>(specializedName, _window, windowid,xmlfile)
{ }

// Another skip level hack
bool skipLevelOnMessage(CGUIMessage& message)
{ TRACE; return CGUIWindow::OnMessage(message); }
};

#undef checkedb
Expand Down
47 changes: 14 additions & 33 deletions xbmc/interfaces/legacy/WindowXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ namespace XBMCAddon
RESOLUTION_INFO res;
CStdString strSkinPath = g_SkinInfo->GetSkinPath(xmlFilename, &res);

CLog::Log(LOGDEBUG,"NEWADDON Skin Path1:%s",strSkinPath.c_str());

if (!XFILE::CFile::Exists(strSkinPath))
{
CStdString str("none");
Expand Down Expand Up @@ -302,7 +300,10 @@ namespace XBMCAddon

bool WindowXML::OnMessage(CGUIMessage& message)
{
#ifdef ENABLE_TRACE_API
TRACE;
CLog::Log(LOGDEBUG,"%sMessage id:%d",_tg.getSpaces(),(int)message.GetMessage());
#endif

// TODO: We shouldn't be dropping down to CGUIWindow in any of this ideally.
// We have to make up our minds about what python should be doing and
Expand Down Expand Up @@ -395,7 +396,7 @@ namespace XBMCAddon
break;
}

return ref(window)->OnMessage(message);
return A(CGUIMediaWindow::OnMessage(message));
}

void WindowXML::AllocResources(bool forceLoad /*= FALSE */)
Expand Down Expand Up @@ -546,44 +547,24 @@ namespace XBMCAddon
CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
if (pWindow)
g_windowManager.ShowOverlay(pWindow->GetOverlayState());
return interceptor->skipLevelOnMessage(message);
return A(CGUIWindow::OnMessage(message));
}
return WindowXML::OnMessage(message);
}

bool WindowXMLDialog::OnAction(const CAction &action)
{
TRACE;

switch (action.GetID())
{
case HACK_CUSTOM_ACTION_OPENING:
{
// This is from the CGUIPythonWindowXMLDialog::Show_Internal
g_windowManager.RouteToWindow(window->get());
// active this dialog...
CGUIMessage msg(GUI_MSG_WINDOW_INIT,0,0);
OnMessage(msg);
// TODO: Figure out how to clean up the CAction
window->setActive(true);
return true;
}
break;

case HACK_CUSTOM_ACTION_CLOSING:
{
// This is from the CGUIPythonWindowXMLDialog::Show_Internal
CGUIMessage msg(GUI_MSG_WINDOW_DEINIT,0,0);
OnMessage(msg);
g_windowManager.RemoveDialog(ref(window)->GetID());
// TODO: Figure out how to clean up the CAction
return true;
}
break;
}

return WindowXML::OnAction(action);
return WindowDialogMixin::OnAction(action) ? true : WindowXML::OnAction(action);
}

void WindowXMLDialog::OnDeinitWindow(int nextWindowID)
{
TRACE;
g_windowManager.RemoveDialog(interceptor->GetID());
WindowXML::OnDeinitWindow(nextWindowID);
}

}

}
10 changes: 9 additions & 1 deletion xbmc/interfaces/legacy/WindowXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ namespace XBMCAddon

SWIGHIDDENVIRTUAL bool IsMediaWindow() const { TRACE; return true; };

// This method is identical to the Window::OnDeinitWindow method
// except it passes the message on to their respective parents.
// Since the respective parent differences are handled by the
// interceptor there's no reason to define this one here.
//SWIGHIDDENVIRTUAL void OnDeinitWindow(int nextWindowID);


protected:
// CGUIWindow
SWIGHIDDENVIRTUAL bool LoadXML(const String &strPath, const String &strPathLower);
Expand Down Expand Up @@ -134,11 +141,12 @@ namespace XBMCAddon

#ifndef SWIG
SWIGHIDDENVIRTUAL bool OnMessage(CGUIMessage &message);
SWIGHIDDENVIRTUAL bool IsDialogRunning() const { return WindowDialogMixin::IsDialogRunning(); }
SWIGHIDDENVIRTUAL bool IsDialogRunning() const { TRACE; return WindowDialogMixin::IsDialogRunning(); }
SWIGHIDDENVIRTUAL bool IsDialog() const { TRACE; return true;};
SWIGHIDDENVIRTUAL bool IsModalDialog() const { TRACE; return true; };
SWIGHIDDENVIRTUAL bool IsMediaWindow() const { TRACE; return false; };
SWIGHIDDENVIRTUAL bool OnAction(const CAction &action);
SWIGHIDDENVIRTUAL void OnDeinitWindow(int nextWindowID);
#endif

SWIGHIDDENVIRTUAL inline void show() { WindowDialogMixin::show(); }
Expand Down

0 comments on commit b4f3914

Please sign in to comment.