Beispiel #1
0
  PyObject* PlayList_Add(PlayList *self, PyObject *args, PyObject *kwds)
  {
    static const char *keywords[] = {
      "url",
      "listitem",
      "index",
      NULL};

    PyObject *pObjectUrl = NULL;
    PyObject *pObjectListItem = NULL;
    int iPos = -1;

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"O|Ol",
      (char**)keywords,
      &pObjectUrl,
      &pObjectListItem,
      &iPos))
    {
      return NULL;
    }

    CStdString strUrl = "";
    if (!PyGetUnicodeString(strUrl, pObjectUrl)) return NULL;

    if (pObjectListItem != NULL && !ListItem_CheckExact(pObjectListItem))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type ListItem!");
      return NULL;
    }

    CFileItemList items;

    if (pObjectListItem != NULL && ListItem_CheckExact(pObjectListItem))
    {
      // an optional listitem was passed
      ListItem* pListItem = NULL;
      pListItem = (ListItem*)pObjectListItem;

      // set m_strPath to the passed url
      pListItem->item->m_strPath = strUrl;

      items.Add(pListItem->item);
    }
    else
    {
      CFileItemPtr item(new CFileItem(strUrl, false));
        item->SetLabel(strUrl);

      items.Add(item);
    }

    self->pPlayList->Insert(items, iPos);

    Py_INCREF(Py_None);
    return Py_None;
  }
Beispiel #2
0
  PyObject* XBMCPLUGIN_AddDirectoryItem(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
    static const char *keywords[] = { "handle", "url", "listitem", "isFolder", "totalItems", NULL };
    int handle = -1;
    PyObject *pURL = NULL;
    PyObject *pItem = NULL;
    char bIsFolder = false;
    int iTotalItems = 0;
    // parse arguments
    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"iOO|bl",
      (char**)keywords,
      &handle,
      &pURL,
      &pItem,
      &bIsFolder,
      &iTotalItems
      ))
    {
      return NULL;
    };

    string url;
    if (!PyXBMCGetUnicodeString(url, pURL, 1) || !ListItem_CheckExact(pItem)) return NULL;

    ListItem *pListItem = (ListItem *)pItem;
    pListItem->item->m_strPath = url;
    pListItem->item->m_bIsFolder = (0 != bIsFolder);

    // call the directory class to add our item
    bool bOk = XFILE::CPluginDirectory::AddItem(handle, pListItem->item.get(), iTotalItems);
    return Py_BuildValue((char*)"b", bOk);
  }
Beispiel #3
0
  PyObject* WindowXML_AddItem(WindowXML *self, PyObject *args)
  {
    if (!self->pWindow) return NULL;

    PyObject *pObject;
    int itemPosition = INT_MAX;
    if (!PyArg_ParseTuple(args, (char*)"O|i", &pObject, &itemPosition)) return NULL;

    string strText;
    ListItem* pListItem = NULL;

    if (ListItem_CheckExact(pObject))
    {
      // object is a listitem
      pListItem = (ListItem*)pObject;
      Py_INCREF(pListItem);
    }
    else
    {
      // object is probably a text item
      if (!PyXBMCGetUnicodeString(strText, pObject, 1)) return NULL;
      // object is a unicode string now, create a new ListItem
      pListItem = ListItem_FromString(strText);
    }

    CGUIPythonWindowXML * pwx = (CGUIPythonWindowXML*)self->pWindow;

    // Tells the window to add the item to FileItem vector
    PyXBMCGUILock();
    pwx->AddItem(pListItem->item, itemPosition);
    PyXBMCGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Beispiel #4
0
  PyObject* ControlList_AddItem(ControlList *self, PyObject *args)
  {
    PyObject *pObject;
    if (!PyArg_ParseTuple(args, (char*)"O", &pObject))  return NULL;

    ListItem* pListItem = NULL;
    if (ListItem_CheckExact(pObject))
    {
      // object is a listitem
      pListItem = (ListItem*)pObject;
      Py_INCREF(pListItem);
    }
    else
    {
      string strText;
      // object is probably a text item
      if (!PyGetUnicodeString(strText, pObject, 1)) return NULL;
      // object is a unicode string now, create a new ListItem
      pListItem = ListItem_FromString(strText);
    }

    // add item to objects vector
    self->vecItems.push_back(pListItem);

    // create message
    CGUIMessage msg(GUI_MSG_LABEL_ADD, self->iParentId, self->iControlId, 0, 0, pListItem->item);

    // send message
    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->OnMessage(msg);
    PyGUIUnlock();

    Py_INCREF(Py_None);
    return Py_None;
  }
Beispiel #5
0
  PyObject* ControlList_AddItems(ControlList *self, PyObject *args, PyObject *kwds)
  {
    PyObject *pList = NULL;
    static const char *keywords[] = { "items", NULL };

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"O",
      (char**)keywords,
      &pList) || pList == NULL || !PyObject_TypeCheck(pList, &PyList_Type))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type List");
      return NULL;
    }

    CFileItemList items;
    for (int item = 0; item < PyList_Size(pList); item++)
    {
      PyObject *pItem = PyList_GetItem(pList, item);

      ListItem* pListItem = NULL;
      if (ListItem_CheckExact(pItem))
      {
        // object is a listitem
        pListItem = (ListItem*)pItem;
        Py_INCREF(pListItem);
      }
      else
      {
        string strText;
        // object is probably a text item
        if (!PyGetUnicodeString(strText, pItem, 1)) return NULL;
        // object is a unicode string now, create a new ListItem
        pListItem = ListItem_FromString(strText);
      }

      // add item to objects vector
      self->vecItems.push_back(pListItem);
      items.Add(pListItem->item);
    }

    // create message
    CGUIMessage msg(GUI_MSG_LABEL_BIND, self->iParentId, self->iControlId, 0, 0, &items);

    // send message
    PyGUILock();
    if (self->pGUIControl) self->pGUIControl->OnMessage(msg);
    PyGUIUnlock();


    Py_INCREF(Py_None);
    return Py_None;
  }
Beispiel #6
0
  PyObject* XBMCPLUGIN_AddDirectoryItems(PyTypeObject *type, PyObject *args, PyObject *kwds)
  {
    int handle = -1;
    PyObject *pItems = NULL;

    static const char *keywords[] = { "handle", "items", "totalItems", NULL };

    int totalItems = 0;
    // parse arguments
    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"iO|l",
      (char**)keywords,
      &handle,
      &pItems,
      &totalItems
      ))
    {
      return NULL;
    };

    CFileItemList items;
    for (int item = 0; item < PyList_Size(pItems); item++)
    {
      PyObject *pItem = PyList_GetItem(pItems, item);
      PyObject *pURL = NULL;
      char bIsFolder = false;
      // parse arguments
      if (!PyArg_ParseTuple(
        pItem,
        (char*)"OO|b",
        &pURL,
        &pItem,
        &bIsFolder
        ))
      {
        return NULL;
      };

      string url;
      if (!PyXBMCGetUnicodeString(url, pURL, 1) || !ListItem_CheckExact(pItem)) return NULL;

      ListItem *pListItem = (ListItem *)pItem;
      pListItem->item->m_strPath = url;
      pListItem->item->m_bIsFolder = (0 != bIsFolder);
      items.Add(pListItem->item);
    }
    // call the directory class to add our items
    bool bOk = XFILE::CPluginDirectory::AddItems(handle, &items, totalItems);

    return Py_BuildValue((char*)"b", bOk);
  }
Beispiel #7
0
  PyObject* ControlList_SetStaticContent(ControlList *self, PyObject *args, PyObject *kwds)
  {
    PyObject *pList = NULL;
    static const char *keywords[] = { "items", NULL };

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"O",
      (char**)keywords,
      &pList) || pList == NULL || !PyObject_TypeCheck(pList, &PyList_Type))
    {
      PyErr_SetString(PyExc_TypeError, "Object should be of type List");
      return NULL;
    }

    vector<CGUIListItemPtr> items;
    
    for (int item = 0; item < PyList_Size(pList); item++)
    {
      PyObject *pItem = PyList_GetItem(pList, item);
      if (!ListItem_CheckExact(pItem))
      {
        PyErr_SetString(PyExc_TypeError, "Only ListItems can be passed");
        return NULL;
      }
      // object is a listitem, and we set m_idpeth to 0 as this
      // is used as the visibility condition for the item in the list
      ListItem *listItem = (ListItem*)pItem;
      listItem->item->m_idepth = 0;

      items.push_back((CFileItemPtr &)listItem->item);
    }
    // set static list
    ((CGUIBaseContainer *)self->pGUIControl)->SetStaticContent(items);

    Py_INCREF(Py_None);
    return Py_None;
  }
  PyObject* ControlList_AddItem(ControlList *self, PyObject *args)
  {
    PyObject *pObject;
    if (!PyArg_ParseTuple(args, (char*)"O", &pObject))  return NULL;

    ListItem* pListItem = NULL;
    if (ListItem_CheckExact(pObject))
    {
      // object is a listitem
      pListItem = (ListItem*)pObject;
      Py_INCREF(pListItem);
    }
    else
    {
      string strText;
      // object is probably a text item
      if (!PyXBMCGetUnicodeString(strText, pObject, 1)) return NULL;
      // object is a unicode string now, create a new ListItem
      pListItem = ListItem_FromString(strText);
    }

    // add item to objects vector
    self->vecItems.push_back(pListItem);

    // construct a CFileItemList to pass 'em on to the list
    CGUIListItemPtr items(new CFileItemList());
    for (unsigned int i = 0; i < self->vecItems.size(); i++)
      ((CFileItemList*)items.get())->Add(self->vecItems[i]->item);

    CGUIMessage msg(GUI_MSG_LABEL_BIND, self->iParentId, self->iControlId, 0, 0, items);
    msg.SetPointer(items.get());
    g_windowManager.SendThreadMessage(msg, self->iParentId);

    Py_INCREF(Py_None);
    return Py_None;
  }
Beispiel #9
0
  // play a file or python playlist
  PyObject* Player_Play(Player *self, PyObject *args, PyObject *kwds)
  {
    PyObject *pObject = NULL;
    PyObject *pObjectListItem = NULL;
    char bWindowed = false;
    static const char *keywords[] = { "item", "listitem", "windowed", NULL };

    if (!PyArg_ParseTupleAndKeywords(
      args,
      kwds,
      (char*)"|OOb",
      (char**)keywords,
      &pObject,
      &pObjectListItem,
      &bWindowed))
    {
      return NULL;
    }

    // set fullscreen or windowed
    g_settings.m_bStartVideoWindowed = (0 != bWindowed);

    // force a playercore before playing
    g_application.m_eForcedNextPlayer = self->playerCore;

    if (pObject == NULL)
    {
      // play current file in playlist
      if (g_playlistPlayer.GetCurrentPlaylist() != self->iPlayList)
      {
        g_playlistPlayer.SetCurrentPlaylist(self->iPlayList);
      }

      CPyThreadState pyState;
      g_application.getApplicationMessenger().PlayListPlayerPlay(g_playlistPlayer.GetCurrentSong());
    }
    else if ((PyString_Check(pObject) || PyUnicode_Check(pObject)) && pObjectListItem != NULL && ListItem_CheckExact(pObjectListItem))
    {
      // an optional listitem was passed
      ListItem* pListItem = NULL;
      pListItem = (ListItem*)pObjectListItem;

      // set m_strPath to the passed url
      pListItem->item->SetPath(PyString_AsString(pObject));

      CPyThreadState pyState;
      g_application.getApplicationMessenger().PlayFile((const CFileItem)*pListItem->item, false);
    }
    else if (PyString_Check(pObject) || PyUnicode_Check(pObject))
    {
      CFileItem item(PyString_AsString(pObject), false);

      CPyThreadState pyState;
      g_application.getApplicationMessenger().MediaPlay(item.GetPath());
    }
    else if (PlayList_Check(pObject))
    {
      // play a python playlist (a playlist from playlistplayer.cpp)
      PlayList* pPlayList = (PlayList*)pObject;
      self->iPlayList = pPlayList->iPlayList;
      g_playlistPlayer.SetCurrentPlaylist(pPlayList->iPlayList);

      CPyThreadState pyState;
      g_application.getApplicationMessenger().PlayListPlayerPlay();
    }

    Py_INCREF(Py_None);
    return Py_None;
  }