예제 #1
0
int runblorb(char *path, char *game)
{
    char magic[4];
    strid_t file;
    giblorb_result_t res;
    giblorb_err_t err;
    giblorb_map_t *map;

    sprintf(tmp, "Could not load Blorb file:\n%s\n", game);

    file = glkunix_stream_open_pathname(game, 0, 0);
    if (!file)
    {
        winmsg(tmp);
        return FALSE;
    }

    err = giblorb_create_map(file, &map);
    if (err)
    {
        winmsg(tmp);
        return FALSE;
    }

    err = giblorb_load_resource(map, giblorb_method_FilePos,
            &res, giblorb_ID_Exec, 0);
    if (err)
    {
        winmsg(tmp);
        return FALSE;
    }

    glk_stream_set_position(file, res.data.startpos, 0);
    glk_get_buffer_stream(file, magic, 4);

    switch (res.chunktype)
    {
        case ID_ZCOD:
            if (strlen(terp))
                return winterp(path, strcat(exe,terp), flags, game);
            else if (magic[0] == 6)
                return winterp(path, strcat(exe,T_ZSIX), flags, game);
            else
                return winterp(path, strcat(exe,T_ZCODE), flags, game);
            break;

        case ID_GLUL:
            if (strlen(terp))
                return winterp(path, strcat(exe,terp), flags, game);
            else
                return winterp(path, strcat(exe,T_GLULX), flags, game);
            break;

        default:
            sprintf(tmp, "Unknown game type in Blorb file:\n%s\n", game);
            winmsg(tmp);
    }
    
    return FALSE;
}
예제 #2
0
int urldecode(char *decoded, unsigned int maxlen, const char *encoded)
{
    unsigned int i;
    int convert, ascii;
    char buffer[3] = {0};
    FILE * file;

    memset(decoded, 0, maxlen);
    convert = FALSE;

    for(i = 0; i < strlen(encoded); ++i)
    {
        if (!convert)
        {
            if (!(strlen(decoded) < maxlen - 1))
                break;

            if(encoded[i] != '%')
                strncat(decoded, &encoded[i], 1);
            else
                convert = TRUE;
         }

        else
        {
            if (strlen(&encoded[i]) < 2)
                break;

            strncpy(buffer, &encoded[i], 2);
            buffer[2] = '\0';

            if (!isxdigit(buffer[0]) || !isxdigit(buffer[1]))
                break;

            if (sscanf(buffer, "%x", &ascii) != 1)
                break;

            if (!(strlen(decoded) < maxlen - 1))
                break;

            strncat(decoded, (char*)&ascii, 1);

            convert = FALSE;
            i++;
        }
    }

    while (strlen(decoded) && decoded[strlen(decoded)-1] == '/')
        decoded[strlen(decoded)-1] = '\0';

    if (!(file = fopen(decoded, "r")))
    {
        snprintf(decoded, maxlen, "Could not open URL path:\n%s\n", encoded);
        winmsg(decoded);
        exit(EXIT_FAILURE);
    }

    fclose(file);
    return 1;
}
예제 #3
0
파일: launchgtk.c 프로젝트: cspiegel/garglk
int winterp(char *path, char *exe, char *flags, char *game)
{
    sprintf(tmp, LaunchingTemplate, path, exe);

    setenv("GARGLK_INI", path, FALSE);

    char *args[4] = {NULL, NULL, NULL, NULL};

    if (strstr(flags, "-"))
    {
        args[0] = exe;
        args[1] = flags;
        args[2] = game;
    }
    else
    {
        args[0] = exe;
        args[1] = buf;
    }

    if (!winexec(tmp, args))
    {
        winmsg("Could not start 'terp.\nSorry.");
        return FALSE;
    }

    return TRUE;
}
예제 #4
0
void CGUIWindowBoxeeMediaMain::OnItemLoaded(CFileItem* pItem) 
{
  if (!pItem)
    return;

  CGUIMessage winmsg(MSG_ITEM_LOADED, GetID(), 0);
  winmsg.SetPointer(new CFileItem(*pItem));
  g_windowManager.SendThreadMessage(winmsg, GetID());  
}
예제 #5
0
int winterp(char *path, char *exe, char *flags, char *game)
{
    sprintf(tmp, LaunchingTemplate, path, exe, flags, game);

    if (!winexec(tmp, NULL)) {
        winmsg("Could not start 'terp.\nSorry.");
        return FALSE;
    }

    return TRUE;
}
예제 #6
0
void CGUIWindowBoxeeMediaMain::LoadMediaItems()
{
  Cleanup();

  LoadMediaItems(m_listMediaItems);
  LoadAppItems(m_listApps);
  
  m_listMediaItemsSmall.Append(m_listMediaItems);
  m_listAppsSmall.Append(m_listApps);

  CLog::Log(LOGDEBUG,"%s - loaded %d media items and %d applications", __FUNCTION__, m_listMediaItems.Size(), m_listApps.Size());

  int i;
  for (i=0; i<m_listMediaItems.Size(); i++) 
  {
    CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST, 0, 0, m_listMediaItems[i]);
    OnMessage(winmsg);
    CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), MEDIA_ITEMS_LIST_SMALL, 0, 0, m_listMediaItemsSmall[i]);
    OnMessage(winmsg2);
  }

  for (i=0; i<m_listApps.Size(); i++) 
  {
    CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST, 0, 0, m_listApps[i]);
    OnMessage(winmsg);
    CGUIMessage winmsg2(GUI_MSG_LABEL_ADD, GetID(), APPS_ITEMS_LIST_SMALL, 0, 0, m_listAppsSmall[i]);
    OnMessage(winmsg2);
  }
  
  // Load thumbnails for the items
  CLog::Log(LOGDEBUG,"Loading thumbnail for %d items", m_listMediaItems.Size()); 
  m_listMediaItems.FillInDefaultIcons();


  m_Loader = GetLoader();
  CFileItemList *pList = new CFileItemList;
  pList->Append(m_listMediaItems);
  pList->Append(m_listApps);
  m_Loader->SetObserver(this);
  m_Loader->Load(*pList);
}
예제 #7
0
void winpath(char *buffer)
{
    char exepath[MaxBuffer] = {0};
    unsigned int exelen;

    exelen = GetModuleFileName(NULL, exepath, sizeof(exepath));

    if (exelen <= 0 || exelen >= MaxBuffer) {
        winmsg("Unable to locate executable path");
        exit(EXIT_FAILURE);
    }

    strcpy(buffer, exepath);

    char *dirpos = strrchr(buffer, *DirSeparator);
    if ( dirpos != NULL )
        *dirpos = '\0';

   return;
}
예제 #8
0
파일: launchgtk.c 프로젝트: cspiegel/garglk
void winpath(char *buffer)
{
    char exepath[MaxBuffer] = {0};
    ssize_t exelen;

    exelen = readlink("/proc/self/exe", exepath, sizeof(exepath));

    if (exelen <= 0 || exelen >= MaxBuffer)
    {
        winmsg("Unable to locate executable path");
        exit(EXIT_FAILURE);
    }

    strcpy(buffer, exepath);

    char *dirpos = strrchr(buffer, *DirSeparator);
    if ( dirpos != NULL )
        *dirpos = '\0';

    return;
}
예제 #9
0
int rungame(char *path, char *game)
{
    /* initialize buffers */
    strcpy(exe, GARGLKPRE);
    strcpy(terp, "");
    strcpy(flags, "");

    configterp(path, game);

    char *ext = strrchr(game, '.');

    if (ext)
        ext++;
    else
        ext = "";

    if (!strcasecmp(ext, "blb"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "blorb"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "glb"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "gbl"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "gblorb"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "zlb"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "zbl"))
        return runblorb(path, game);
    if (!strcasecmp(ext, "zblorb"))
        return runblorb(path, game);

    if (strlen(terp))
        return winterp(path, strcat(exe,terp), flags, game);

    if (!strcasecmp(ext, "dat"))
        return winterp(path, strcat(exe,T_ADVSYS), "", game);

    if (!strcasecmp(ext, "d$$"))
        return winterp(path, strcat(exe,T_AGT), "-gl", game);
    if (!strcasecmp(ext, "agx"))
        return winterp(path, strcat(exe,T_AGT), "-gl", game);

    if (!strcasecmp(ext, "acd"))
        return winterp(path, strcat(exe,T_ALAN2), "", game);

    if (!strcasecmp(ext, "a3c"))
        return winterp(path, strcat(exe,T_ALAN3), "", game);

    if (!strcasecmp(ext, "taf"))
        return winterp(path, strcat(exe,T_ADRIFT), "", game);

    if (!strcasecmp(ext, "ulx"))
        return winterp(path, strcat(exe,T_GLULX), "", game);

    if (!strcasecmp(ext, "hex"))
        return winterp(path, strcat(exe,T_HUGO), "", game);

    if (!strcasecmp(ext, "jacl"))
        return winterp(path, strcat(exe,T_JACL), "", game);
    if (!strcasecmp(ext, "j2"))
        return winterp(path, strcat(exe,T_JACL), "", game);

    if (!strcasecmp(ext, "gam"))
        return winterp(path, strcat(exe,T_TADS2), "", game);

    if (!strcasecmp(ext, "t3"))
        return winterp(path, strcat(exe,T_TADS3), "", game);

    if (!strcasecmp(ext, "z1"))
        return winterp(path, strcat(exe,T_ZOLD), "", game);
    if (!strcasecmp(ext, "z2"))
        return winterp(path, strcat(exe,T_ZOLD), "", game);

    if (!strcasecmp(ext, "z3"))
        return winterp(path, strcat(exe,T_ZCODE), "", game);
    if (!strcasecmp(ext, "z4"))
        return winterp(path, strcat(exe,T_ZCODE), "", game);
    if (!strcasecmp(ext, "z5"))
        return winterp(path, strcat(exe,T_ZCODE), "", game);
    if (!strcasecmp(ext, "z7"))
        return winterp(path, strcat(exe,T_ZCODE), "", game);
    if (!strcasecmp(ext, "z8"))
        return winterp(path, strcat(exe,T_ZCODE), "", game);

    if (!strcasecmp(ext, "z6"))
        return winterp(path, strcat(exe,T_ZSIX), "", game);

    if (!strcasecmp(ext, "l9"))
        return winterp(path, strcat(exe,T_LEV9), "", game);
    if (!strcasecmp(ext, "sna"))
        return winterp(path, strcat(exe,T_LEV9), "", game);
    if (!strcasecmp(ext, "mag"))
        return winterp(path, strcat(exe,T_MGSR), "", game);

    if (!strcasecmp(ext, "asl"))
        return winterp(path, strcat(exe,T_QUEST), "", game);
    if (!strcasecmp(ext, "cas"))
        return winterp(path, strcat(exe,T_QUEST), "", game);

    if (!strcasecmp(ext, "saga"))
        return winterp(path, strcat(exe,T_SCOTT), "", game);

    sprintf(tmp, "Unknown file type: \"%s\"\nSorry.", ext);
    winmsg(tmp);
    
    return FALSE;
}
예제 #10
0
bool CGUIDialogBoxeeCtx::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
  case GUI_MSG_ITEM_LOADED:
  {
    // New data received from the item loader, update existing item
    CFileItemPtr pItem ((CFileItem *)message.GetPointer());
    message.SetPointer(NULL);
    if (pItem) {
      m_item = *pItem;
      CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), INFO_HIDDEN_LIST, 0);
      OnMessage(msg);
      
      CGUIMessage winmsg(GUI_MSG_LABEL_ADD, GetID(), INFO_HIDDEN_LIST, 0, 0, pItem);
      OnMessage(winmsg);

      CGUIMessage ref1(GUI_MSG_REFRESH_THUMBS, GetID(), IMG1);
      OnMessage(ref1);

      CGUIMessage ref2(GUI_MSG_REFRESH_THUMBS, GetID(), IMG2);
      OnMessage(ref2);

      CGUIMessage ref3(GUI_MSG_REFRESH_THUMBS, GetID(), IMG3);
      OnMessage(ref3);

      CGUIMessage ref4(GUI_MSG_REFRESH_THUMBS, GetID(), IMG4);
      OnMessage(ref4);
    }

    return true;
  }

  case GUI_MSG_CLICKED:
    {
      unsigned int iControl = message.GetSenderId();
      if (iControl == BTN_MORE_INFO)
      {
        OnMoreInfo();
        return true;
      }
      else if (iControl == BTN_RATE)
      {
        bool bLike;
        if (CGUIDialogBoxeeRate::ShowAndGetInput(bLike))
        {
          BoxeeUtils::Rate(&m_item, bLike);
          g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::ICON_STAR, "", g_localizeStrings.Get(51034), 5000 , KAI_YELLOW_COLOR, KAI_GREY_COLOR);
        }
      }
      else if (iControl == BTN_SHARE)
      {
        CGUIDialogBoxeeShare *pShare = (CGUIDialogBoxeeShare *)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_SHARE);

        if (pShare)
        {
          pShare->SetItem(&m_item);
          pShare->DoModal();
        }
        else
        {
          CLog::Log(LOGERROR,"CGUIDialogBoxeeCtx::OnMessage - GUI_MSG_CLICKED - BTN_SHARE - FAILED to get WINDOW_DIALOG_BOXEE_SHARE (share)");
        }
      }
      else if (iControl == BTN_PRESET)
      {
        if (m_item.GetPropertyBOOL("IsPreset"))
        {
          CGUIDialogYesNo* dlgYesNo = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
          if (dlgYesNo)
          {
            dlgYesNo->SetHeading(51020);
            dlgYesNo->SetLine(0, 51021);
            dlgYesNo->SetLine(1, m_item.GetLabel() + "?");
            dlgYesNo->SetLine(2, "");
            dlgYesNo->DoModal();

            if (dlgYesNo->IsConfirmed())
            {
              g_settings.DeleteSource(GetItemShareType(), m_item.GetProperty("ShareName"), m_item.m_strPath);
              CGUIWindow *pWindow = g_windowManager.GetWindow(g_windowManager.GetActiveWindow());
              if (pWindow)
              {
                CGUIMessage msg(GUI_MSG_REFRESH_APPS, 0, 0);
                pWindow->OnMessage(msg);
              }
            }
          }
        } 
        else
        {
          CMediaSource newShare;
          newShare.strPath = m_item.m_strPath;
          newShare.strName = m_item.GetLabel();
          if (m_item.HasProperty("OriginalThumb") && !m_item.GetProperty("OriginalThumb").IsEmpty())
            newShare.m_strThumbnailImage = m_item.GetProperty("OriginalThumb");
          else
            newShare.m_strThumbnailImage = m_item.GetThumbnailImage();
          newShare.vecPaths.push_back(m_item.m_strPath);
          g_settings.AddShare(GetItemShareType(), newShare);
        }
        Close();
        return true;
      }
      else if (iControl == BTN_QUALITY)
      {
        return HandleQualityList();
    }
    }
    break;
  case GUI_MSG_WINDOW_DEINIT:
  case GUI_MSG_VISUALISATION_UNLOADING:
    {
    }
    break;
  case GUI_MSG_VISUALISATION_LOADED:
    {
    }
  }
  return CGUIDialog::OnMessage(message);
}