Exemple #1
0
bool Export(AudacityProject *project,
            bool selectionOnly, double t0, double t1)
{
   wxString fName;
   wxString formatStr;
   wxString extension;
   wxString actualName;
   bool     success;
   int      format;
   bool     stereo;
   
   format = ReadExportFormatPref();
                         
   formatStr = sf_header_name(format & SF_FORMAT_TYPEMASK);
   extension = "." + sf_header_extension(format & SF_FORMAT_TYPEMASK);

   fName = ExportCommon(project, formatStr, extension,
                        selectionOnly, &t0, &t1, &stereo,
                        actualName);

   if (fName == "")
      return false;

   success = ::ExportPCM(project, stereo, fName,
                         selectionOnly, t0, t1);

   if (success && actualName != fName)
      ::wxRenameFile(FILENAME(fName), FILENAME(actualName));

   return success;
}
Exemple #2
0
bool AudacityApp::CreateSingleInstanceChecker(wxString dir)
{
   wxLogNull dontLog;

   wxString name = wxString::Format(wxT("audacity-lock-%s"), wxGetUserId().c_str());
   mChecker = new wxSingleInstanceChecker();

   if (!mChecker->Create(FILENAME(name), FILENAME(dir))) {
      // Error initializing the wxSingleInstanceChecker.  We don't know
      // whether there is another instance running or not.

      wxString prompt =
         _("Audacity was not able to lock the temporary files directory.\nThis folder may be in use by another copy of Audacity.\nRunning two copies of Audacity simultaneously may cause\ndata loss or cause your system to crash.\n\nDo you still want to start Audacity?");
      int action = wxMessageBox(prompt,
                                _("Error locking temporary folder"),
                                wxYES_NO | wxICON_EXCLAMATION,
                                NULL);
      if (action == wxNO) {
         delete mChecker;
         return false;
      }
   }
   else if ( mChecker->IsAnotherRunning() ) {
      // There is another copy of Audacity running.  Force quit.
      
      wxString prompt =
         _("The system has detected that another copy of Audacity is running.\nRunning two copies of Audacity simultaneously may lead to\ndata loss or cause your system to crash, so is not allowed.\n\nUse the New or Open commands in the currently running Audacity\nprocess to open multiple projects simultaneously.\n");
      wxMessageBox(prompt, _("Audacity is already running"),
            wxOK | wxICON_ERROR);
      delete mChecker;
      return false;
   }

   return true;
}
Exemple #3
0
// Adds one to the reference count of the block file,
// UNLESS it is "locked", then it makes a new copy of
// the BlockFile.
BlockFile *DirManager::CopyBlockFile(BlockFile *b)
{
    if (!b->IsLocked()) {
        b->Ref();
        return b;
    }

    wxString dir = (projFull != ""? projFull: temp);
    wxFileName newFile = MakeBlockFileName(dir);

    // We assume that the new file should have the same extension
    // as the existing file
    newFile.SetExt(b->GetFileName().GetExt());

    if( !wxCopyFile(FILENAME(b->GetFileName().GetFullPath()),
                    FILENAME(newFile.GetFullPath())) )
        return NULL;

    BlockFile *b2 = b->Copy(newFile);

    if (b2 == NULL)
        return NULL;

    blockFileHash->Put(newFile.GetName(), (wxObject *) b2);
    aliasList.Add(newFile.GetFullPath());

    CheckHashTableSize();

    return b2;
}
Exemple #4
0
 AutoRollbackRenamer(wxString oldName, wxString newName) {
    mOldName = oldName;
    mNewName = newName;
    mRenameSucceeded = ::wxRenameFile(FILENAME(mOldName), FILENAME(mNewName));
    mFinished = false;
    mNewFile = NULL;
 }
static APTR build_drive_gui(void)
{
    APTR app, ui, ok, cancel;

    app = mui_get_app();

    ui = GroupObject,
    FILENAME(ui_to_from_drive[0].object, "1541", hook_object_drive[0])
    FILENAME(ui_to_from_drive[1].object, "1541-II", hook_object_drive[1])
    FILENAME(ui_to_from_drive[2].object, "1570", hook_object_drive[2])
    FILENAME(ui_to_from_drive[3].object, "1571", hook_object_drive[3])
    FILENAME(ui_to_from_drive[4].object, "1581", hook_object_drive[4])
    FILENAME(ui_to_from_drive[5].object, "2031", hook_object_drive[5])
    FILENAME(ui_to_from_drive[6].object, "2030", hook_object_drive[6])
    FILENAME(ui_to_from_drive[7].object, "3040", hook_object_drive[7])
    FILENAME(ui_to_from_drive[8].object, "4040", hook_object_drive[8])
    FILENAME(ui_to_from_drive[9].object, "1001", hook_object_drive[9])
    OK_CANCEL_BUTTON
    End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(hook_object_drive[0], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive0);

        DoMethod(hook_object_drive[1], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive1);

        DoMethod(hook_object_drive[2], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive2);

        DoMethod(hook_object_drive[3], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive3);

        DoMethod(hook_object_drive[4], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive4);

        DoMethod(hook_object_drive[5], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive5);

        DoMethod(hook_object_drive[6], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive6);

        DoMethod(hook_object_drive[7], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive7);

        DoMethod(hook_object_drive[8], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive8);

        DoMethod(hook_object_drive[9], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseDrive9);
    }

    return ui;
}
static APTR build_computer_gui(void)
{
    APTR app, ui, ok, cancel;

    app = mui_get_app();

    ui = GroupObject,
           FILENAME(ui_to_from_computer[0].object, "Kernal", hook_object_computer[0])
           FILENAME(ui_to_from_computer[1].object, "Basic", hook_object_computer[1])
           FILENAME(ui_to_from_computer[2].object, "Character", hook_object_computer[2])
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(hook_object_computer[0], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseComputer0);

        DoMethod(hook_object_computer[1], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseComputer1);

        DoMethod(hook_object_computer[2], MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseComputer2);
    }

    return ui;
}
Exemple #7
0
void write_comment(TreeState *state)
{
    fprintf(FILENAME(state), "    /* ");
    IDL_tree_to_IDL(state->tree, state->ns, FILENAME(state),
                    IDLF_OUTPUT_NO_NEWLINES |
                    IDLF_OUTPUT_NO_QUALIFY_IDENTS |
                    IDLF_OUTPUT_PROPERTIES);
    fputs(" */\n", FILENAME(state));
}
Exemple #8
0
bool ExportLossy(AudacityProject *project,
                 bool selectionOnly, double t0, double t1)
{
   wxString fName;
   bool stereo;
   wxString actualName;
   bool     success = false;
   wxString format = gPrefs->Read("/FileFormats/LossyExportFormat", "MP3");

   if( format == "MP3" ) {
      fName = ExportCommon(project, "MP3", ".mp3",
                           selectionOnly, &t0, &t1, &stereo,
                           actualName);

      if (fName == "")
         return false;

      success = ::ExportMP3(project, stereo, fName,
                            selectionOnly, t0, t1);
   }
   else if( format == "OGG" ) {
#ifdef USE_LIBVORBIS
      fName = ExportCommon(project, "OGG", ".ogg",
                           selectionOnly, &t0, &t1, &stereo,
                           actualName);

      if (fName == "")
         return false;

      success = ::ExportOGG(project, stereo, fName,
                      selectionOnly, t0, t1);
#else
      wxMessageBox(_("Ogg Vorbis support is not included in this build of Audacity"));
#endif
   }
   else if( format == "External Program" ) {
#ifdef __WXGTK__
      wxString extension = gPrefs->Read( "/FileFormats/ExternalProgramExportExtension", "" );
      fName = ExportCommon(project, "External Program", "." + extension,
                           selectionOnly, &t0, &t1, &stereo,
                           actualName);

      if (fName == "")
         return false;

      success = ::ExportCL(project, stereo, fName,
                           selectionOnly, t0, t1);
#else
      wxMessageBox(_("Command-line exporting is only supported on UNIX"));
#endif
   }

   if (success && actualName != fName)
      ::wxRenameFile(FILENAME(fName), FILENAME(actualName));

   return success;
}
Exemple #9
0
   ~AutoRollbackRenamer()
   {
      if (mNewFile)
         fclose(mNewFile);

      if (mRenameSucceeded && !mFinished) {
         ::wxRemoveFile(FILENAME(mOldName));
         ::wxRenameFile(FILENAME(mNewName), FILENAME(mOldName));
      }
   }
Exemple #10
0
void LoadLadspaEffect(wxString fname)
{
   wxLogNull logNo;
   LADSPA_Descriptor_Function mainFn = NULL;

   // As a courtesy to some plug-ins that might be bridges to
   // open other plug-ins, we set the current working
   // directory to be the plug-in's directory.

   wxString saveOldCWD = FROMFILENAME(::wxGetCwd());
   wxString prefix = ::wxPathOnly(fname);
   ::wxSetWorkingDirectory(FILENAME(prefix));

#if defined(__WXGTK__) || defined(__WXMAC__)

   void *libHandle = NULL;

   libHandle = dlopen(FILENAME(fname), RTLD_LAZY);
   
   mainFn = (LADSPA_Descriptor_Function)
      dlsym(libHandle, descriptorFnName);

#else
   // The following code uses the wxWindows DLL class, which does
   // not allow us to control the flags passed to dlopen().  This
   // leads to potential segfault bugs when plugins have conflicting
   // symbols, so until wxWindows adds this capability we are calling
   // dlopen() by hand under WXGTK, above...

   wxDllType libHandle = NULL;
     
   libHandle = wxDllLoader::LoadLibrary(FILENAME(fname));
   mainFn = (LADSPA_Descriptor_Function)
      wxDllLoader::GetSymbol(libHandle, descriptorFnName);
#endif

   if (mainFn) {
      int index = 0;
      const LADSPA_Descriptor *data;

      data = mainFn(index);
      while(data) {
         LadspaEffect *effect = new LadspaEffect(data);
         Effect::RegisterEffect(effect);
         
         // Get next plugin
         index++;
         data = mainFn(index);            
      }
   }

   ::wxSetWorkingDirectory(saveOldCWD);
}
Exemple #11
0
bool AudacityApp::InitCleanSpeech()
{
   wxString cwd = FROMFILENAME(::wxGetCwd());
   wxString presetsFromPrefs = gPrefs->Read(wxT("/Directories/PresetsDir"), wxT(""));
   wxString presets = wxT("");

   #ifdef __WXGTK__
   if (presetsFromPrefs.GetChar(0) != wxT('/'))
      presetsFromPrefs = wxT("");
   #endif

   #ifdef __WXMSW__
   wxString presetsDefaultLoc = cwd + wxT("\\presets");
   #else
   wxString presetsDefaultLoc = cwd + wxT("/presets");
   #endif

   // Stop wxWindows from printing its own error messages (not used ... does this really do anything?)
   wxLogNull logNo;

   // Try temp dir that was stored in prefs first
   if (presetsFromPrefs != wxT("")) {
      if (wxDirExists(FILENAME(presetsFromPrefs)))
         presets = presetsFromPrefs;
      else if (wxMkdir(FILENAME(presetsFromPrefs)))
         presets = presetsFromPrefs;
   }

   // If that didn't work, try the default location
   if ((presets == wxT("")) && (presetsDefaultLoc != wxT(""))) {
      if (wxDirExists(FILENAME(presetsDefaultLoc)))
         presets = presetsDefaultLoc;
      else if (wxMkdir(FILENAME(presetsDefaultLoc)))
         presets = presetsDefaultLoc;
   }

   if (presets == wxT("")) {
      // Failed
      wxMessageBox(_("Audacity could not find a place to store\n.csp CleanSpeech preset files\nAudacity is now going to exit. \nInstallation may be corrupt."));
      return false;
   }

   // The permissions don't always seem to be set on
   // some platforms.  Hopefully this fixes it...
   #ifdef __UNIX__
   chmod(FILENAME(presets).fn_str(), 0755);
   #endif

   gPrefs->Write(wxT("/Directories/PresetsDir"), presets);
   return true;
}
Exemple #12
0
bool DirManager::CopyToNewProjectDirectory(BlockFile *f)
{
    wxFileName newFileName(projFull, f->mFileName.GetFullName());
    if ( !(newFileName == f->mFileName) ) {
        bool ok = wxCopyFile(FILENAME(f->mFileName.GetFullPath()),
                             FILENAME(newFileName.GetFullPath()));
        if (ok) {
            f->mFileName = newFileName;
        }
        else
            return false;
    }

    return true;
}
Exemple #13
0
static APTR build_gui_record(void)
{
    APTR app, ui, ok, browse_button, cancel;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseRecordHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse_Record_File, NULL };
#else
    static const struct Hook BrowseRecordHook = { { NULL, NULL }, (VOID *)Browse_Record_File, NULL, NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
           CYCLE(format, translate_text(IDS_SOUND_RECORD_FORMAT), ui_sound_formats)
           FILENAME(ui_to_from_record[0].object, translate_text(IDS_SOUND_RECORD_FILE), browse_button)
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseRecordHook);
    }

    return ui;
}
Exemple #14
0
static APTR build_gui_palette(void)
{
    APTR app, ui, ok, browse_button, cancel;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse_palette, NULL };
#else
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)Browse_palette, NULL, NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
           CYCLE(ui_to_from_palette[0].object, ui_to_from_palette[0].resource, ui_video_enable)
           FILENAME(ui_to_from_palette[1].object, video_palette_filename_text, browse_button)
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseFileHook);
    }

    return ui;
}
Exemple #15
0
static APTR build_gui(void)
{
    APTR app, ui, ok, browse_button, cancel;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse, NULL };
#else
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)Browse, NULL, NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
           CYCLE(ui_to_from[0].object, "DQBB", ui_dqbb_enable)
           FILENAME(ui_to_from[1].object, translate_text(IDS_DQBB_FILENAME), browse_button)
           CYCLE(ui_to_from[2].object, translate_text(IDS_SAVE_DQBB_IMAGE_WHEN_CHANGED), ui_dqbb_enable)
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseFileHook);
    }

    return ui;
}
Exemple #16
0
void MetadataManager::loadConfigFile()
{
	XOJ_CHECK_TYPE(MetadataManager);

	if (this->config)
	{
		return;
	}

	this->config = g_key_file_new();
	g_key_file_set_list_separator(this->config, ',');

	char* file = FILENAME();

	if (g_file_test(file, G_FILE_TEST_EXISTS))
	{
		GError* error = NULL;
		if (!g_key_file_load_from_file(config, file, G_KEY_FILE_NONE, &error))
		{
			g_warning("Metadata file \"%s\" is invalid: %s", file, error->message);
			g_error_free(error);
		}
	}

	g_free(file);
}
Exemple #17
0
static APTR build_gui(void)
{
    APTR app, ui, ok, browse_button, cancel;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)Browse, NULL };
#else
    static const struct Hook BrowseFileHook = { { NULL, NULL }, (VOID *)Browse, NULL, NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
           FILENAME(ui_to_from[0].object, translate_text(IDS_C64DTV_ROM_FILENAME), browse_button)
           CYCLE(ui_to_from[1].object, translate_text(IDS_C64DTV_REVISION), ui_c64dtv_revision)
           CYCLE(ui_to_from[2].object, translate_text(IDS_C64DTV_WRITE_ENABLE), ui_c64dtv_enable)
           CYCLE(ui_to_from[3].object, translate_text(IDS_C64DTV_HUMMER_ADC), ui_c64dtv_enable)
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseFileHook);
    }

    return ui;
}
Exemple #18
0
static krb5_error_code
fcc_open(krb5_context context,
	 krb5_ccache id,
	 int *fd_ret,
	 int flags,
	 mode_t mode)
{
    krb5_boolean exclusive = ((flags | O_WRONLY) == flags ||
			      (flags | O_RDWR) == flags);
    krb5_error_code ret;
    const char *filename = FILENAME(id);
    int fd;
    fd = open(filename, flags, mode);
    if(fd < 0) {
	ret = errno;
	krb5_set_error_message(context, ret, N_("open(%s): %s", "file, error"),
			       filename, strerror(ret));
	return ret;
    }
    rk_cloexec(fd);

    if((ret = fcc_lock(context, id, fd, exclusive)) != 0) {
	close(fd);
	return ret;
    }
    *fd_ret = fd;
    return 0;
}
Exemple #19
0
bool MetadataManager::save(MetadataManager* manager)
{
	XOJ_CHECK_TYPE_OBJ(manager, MetadataManager);

	manager->timeoutId = 0;

	manager->cleanupMetadata();

	gsize length = 0;
	char* data = g_key_file_to_data(manager->config, &length, NULL);
	char* fileName = FILENAME();
	GFile* file = g_file_new_for_path(fileName);

	if (!g_file_replace_contents(file, data, length, NULL, false,
	                             G_FILE_CREATE_PRIVATE, NULL, NULL, NULL))
	{
		g_warning("could not write metadata file: %s", fileName);
	}

	g_free(data);
	g_free(fileName);
	g_object_unref(file);

	return false;
}
Exemple #20
0
static krb5_error_code
fcc_destroy(krb5_context context,
	    krb5_ccache id)
{
    _krb5_erase_file(context, FILENAME(id));
    return 0;
}
Exemple #21
0
void Tags::ImportID3(wxString fileName)
{
#ifdef USE_LIBID3TAG 

   #ifdef _UNICODE
      /* id3_file_open doesn't handle fn_Str() in Unicode build. May or may not actually work. */
      struct id3_file *fp = id3_file_open(FILENAME(fileName).mb_str(),
                                          ID3_FILE_MODE_READONLY);
   #else // ANSI
      struct id3_file *fp = id3_file_open(FILENAME(fileName).fn_str(),
                                          ID3_FILE_MODE_READONLY);
   #endif // Unicode/ANSI

   if (!fp) return;

   struct id3_tag *tp = id3_file_tag(fp);
   if (!tp) return;

   mTitle = GetID3FieldStr(tp, ID3_FRAME_TITLE);
   mArtist = GetID3FieldStr(tp, ID3_FRAME_ARTIST);
   mAlbum = GetID3FieldStr(tp, ID3_FRAME_ALBUM);   
   mYear = GetID3FieldStr(tp, ID3_FRAME_YEAR);
   mComments = GetID3FieldStr(tp, ID3_FRAME_COMMENT);

   long l;
   wxString s;
   if ((s = GetID3FieldStr(tp, ID3_FRAME_TRACK)).ToLong(&l))
      mTrackNum = l;

   mID3V2 = ( tp->options & ID3_TAG_OPTION_ID3V1 ) ? false : true;
   
   s = GetID3FieldStr(tp, ID3_FRAME_GENRE);

   if( mID3V2 ) {
      int numGenres = GetNumGenres();
      for(int i=0; i<numGenres; i++)
         if (0 == s.CmpNoCase(GetGenreNum(i)))
            mGenre = i;
   }
   else {
      if( s.ToLong( &l ) )
         mGenre = l;
   }

   id3_file_close(fp);
#endif // ifdef USE_LIBID3TAG 
}
Exemple #22
0
static krb5_error_code
fcc_close(krb5_context context,
	  krb5_ccache id)
{
    free (FILENAME(id));
    krb5_data_free(&id->data);
    return 0;
}
Exemple #23
0
BlockFile *DirManager::LoadBlockFile(wxTextFile * in, sampleFormat format)
{
    wxASSERT(projFull != "");

    long summaryLen;

    if (!(in->GetNextLine().ToLong(&summaryLen)))
        return NULL;

    wxString blockName = in->GetNextLine();

    bool alias = false;
    wxString aliasFullPath;
    long localLen, start, len, channel;

    if (blockName == "Alias") {
        alias = true;
        aliasFullPath = in->GetNextLine();

        //if (!(in->GetNextLine().ToLong(&localLen)))
        //   return NULL;

        if (!(in->GetNextLine().ToLong(&start)))
            return NULL;
        if (!(in->GetNextLine().ToLong(&len)))
            return NULL;
        if (!(in->GetNextLine().ToLong(&channel)))
            return NULL;

        blockName = in->GetNextLine();
    }

    wxString pathName = projFull + wxFILE_SEP_PATH + blockName;
    BlockFile *retrieved = (BlockFile *) blockFileHash->Get(blockName);
    if (retrieved) {
        wxASSERT(retrieved->IsAlias() == alias);
        retrieved->Ref();
        return retrieved;
    } else {
        BlockFile *newBlockFile =
            new BlockFile(blockName, pathName, summaryLen);

        if (alias) {
            newBlockFile->SetAliasedData(aliasFullPath, start, len, channel);
            aliasList.Add(aliasFullPath);
        }

        newBlockFile->mSampleFormat = format;

        blockFileHash->Put(blockName, (wxObject *) newBlockFile);

        CheckHashTableSize();

        if (!wxFileExists(FILENAME(pathName)))
            return 0;
        return newBlockFile;
    }
}
Exemple #24
0
static APTR build_gui(void)
{
    APTR app, ui, ok, browse_button_bios, browse_button_image, cancel;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseBIOSHook = { { NULL,NULL },(VOID *)HookEntry,(VOID *)Browse_BIOS, NULL};
    static const struct Hook BrowseFileHook = { { NULL,NULL },(VOID *)HookEntry,(VOID *)Browse_Image, NULL};
#else
    static const struct Hook BrowseBIOSHook = { { NULL,NULL },(VOID *)Browse_BIOS,NULL,NULL };
    static const struct Hook BrowseFileHook = { { NULL,NULL },(VOID *)Browse_Image,NULL,NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
    CYCLE(ui_to_from[1].object, "MMC64", ui_mmc64_enable)
    CYCLE(ui_to_from[2].object, translate_text(IDS_BIOS_REVISION), ui_mmc64_bios_revision)
    CYCLE(ui_to_from[3].object, translate_text(IDS_BIOS_FLASH_JUMPER), ui_mmc64_enable)
    CYCLE(ui_to_from[4].object, translate_text(IDS_SAVE_BIOS_WHEN_CHANGED), ui_mmc64_enable)
    FILENAME(ui_to_from[0].object, translate_text(IDS_BIOS_FILE), browse_button_bios)
    CYCLE(ui_to_from[5].object, translate_text(IDS_MMC64_IMAGE_READ_ONLY), ui_mmc64_enable)
    FILENAME(ui_to_from[6].object, translate_text(IDS_MMC64_IMAGE_FILE), browse_button_image)
    OK_CANCEL_BUTTON
    End;

    if (ui != NULL) {
        DoMethod(cancel,
                 MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button_bios, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseBIOSHook);

        DoMethod(browse_button_image, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseFileHook);
    }

    return ui;
}
static APTR build_gui(void)
{
    APTR app, ui, ok, cancel, browse_button1, browse_button2;

#ifdef AMIGA_MORPHOS
    static const struct Hook BrowseInternalHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)BrowseInternal, NULL };
    static const struct Hook BrowseExternalHook = { { NULL, NULL }, (VOID *)HookEntry, (VOID *)BrowseExternal, NULL };
#else
    static const struct Hook BrowseInternalHook = { { NULL, NULL }, (VOID *)BrowseInternal, NULL, NULL };
    static const struct Hook BrowseExternalHook = { { NULL, NULL }, (VOID *)BrowseExternal, NULL, NULL };
#endif

    app = mui_get_app();

    ui = GroupObject,
           CYCLE(ui_to_from[0].object, translate_text(IDS_MACHINE_TYPE), ui_c128_machine_type)
           CYCLE(ui_to_from[1].object, translate_text(IDS_INTERNAL_FUNCTION_ROM), ui_function_rom)
           FILENAME(ui_to_from[2].object, translate_text(IDS_INTERNAL_FUNCTION_ROM_FILENAME), browse_button1)
           CYCLE(ui_to_from[3].object, translate_text(IDS_INTERNAL_FUNCTION_RTC_SAVE), ui_c128_enable)
           CYCLE(ui_to_from[4].object, translate_text(IDS_EXTERNAL_FUNCTION_ROM), ui_function_rom)
           FILENAME(ui_to_from[5].object, translate_text(IDS_EXTERNAL_FUNCTION_ROM_FILENAME), browse_button2)
           CYCLE(ui_to_from[6].object, translate_text(IDS_EXTERNAL_FUNCTION_RTC_SAVE), ui_c128_enable)
           CYCLE(ui_to_from[7].object, translate_text(IDS_RAM_BANKS_2_AND_3), ui_c128_enable)
           OK_CANCEL_BUTTON
         End;

    if (ui != NULL) {
        DoMethod(cancel, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

        DoMethod(ok, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_Application_ReturnID, BTN_OK);

        DoMethod(browse_button1, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseInternalHook);

        DoMethod(browse_button2, MUIM_Notify, MUIA_Pressed, FALSE,
                 app, 2, MUIM_CallHook, &BrowseExternalHook);
    }

    return ui;
}
Exemple #26
0
void InitHelp(wxWindow * parent)
{
   if (!gHelp) {
      wxString defaultLoc;
      wxArrayString helpFiles;

      wxGetApp().FindFilesInPathList("audacity-1.2-help.htb",
                                     wxGetApp().audacityPathList,
                                     wxFILE,
                                     helpFiles);

      if (helpFiles.GetCount() > 0)
         defaultLoc = helpFiles[0];
      else
         defaultLoc = INSTALL_PREFIX "/share/audacity/audacity-1.2-help.htb";

      wxString helpFilePath =
          gPrefs->Read("/Help/HelpFilePath1.2", defaultLoc);

      if (!::wxFileExists(FILENAME(helpFilePath))) {
         helpFilePath = defaultLoc;
      }
      if (!::wxFileExists(FILENAME(helpFilePath))) {
         helpFilePath = wxFileSelector(_("Where is audacity-1.2-help.htb?"), NULL,
                                       "audacity-1.2-help.htb",    // Name
                                       "",                     // Extension
                                       _("HTML Help Books (*.htb)|*.htb"),
                                       wxOPEN, parent);
         if (helpFilePath == "")
            return;
      }

      gHelp = new wxHtmlHelpController();
      if (!gHelp->AddBook(helpFilePath)) {
         wxMessageBox(_("Couldn't open the Audacity Help file."));
         delete gHelp;
         gHelp = NULL;
      }

      gPrefs->Write("/Help/HelpFilePath1.2", helpFilePath);
   }
}
Exemple #27
0
static krb5_error_code
fcc_initialize(krb5_context context,
	       krb5_ccache id,
	       krb5_principal primary_principal)
{
    krb5_fcache *f = FCACHE(id);
    int ret = 0;
    int fd;
    char *filename = f->filename;

    unlink (filename);

    ret = fcc_open(context, id, &fd, O_RDWR | O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC, 0600);
    if(ret)
	return ret;
    {
	krb5_storage *sp;
	sp = krb5_storage_emem();
	krb5_storage_set_eof_code(sp, KRB5_CC_END);
	if(context->fcache_vno != 0)
	    f->version = context->fcache_vno;
	else
	    f->version = KRB5_FCC_FVNO_4;
	ret |= krb5_store_int8(sp, 5);
	ret |= krb5_store_int8(sp, f->version);
	storage_set_flags(context, sp, f->version);
	if(f->version == KRB5_FCC_FVNO_4 && ret == 0) {
	    /* V4 stuff */
	    if (context->kdc_sec_offset) {
		ret |= krb5_store_int16 (sp, 12); /* length */
		ret |= krb5_store_int16 (sp, FCC_TAG_DELTATIME); /* Tag */
		ret |= krb5_store_int16 (sp, 8); /* length of data */
		ret |= krb5_store_int32 (sp, context->kdc_sec_offset);
		ret |= krb5_store_int32 (sp, context->kdc_usec_offset);
	    } else {
		ret |= krb5_store_int16 (sp, 0);
	    }
	}
	ret |= krb5_store_principal(sp, primary_principal);
	
	ret |= write_storage(context, sp, fd);

	krb5_storage_free(sp);
    }
    fcc_unlock(context, fd);
    if (close(fd) < 0)
	if (ret == 0) {
	    ret = errno;
	    krb5_set_error_message (context, ret, N_("close %s: %s", ""),
				    FILENAME(id), strerror(ret));
	}
    return ret;
}
Exemple #28
0
static gboolean
xpcom_to_java_param(TreeState *state) 
{
    IDL_tree param = state->tree;
    state->tree = IDL_PARAM_DCL(param).param_type_spec;

    /*
     * Put in type of parameter
     */

    if (!xpcom_to_java_type(state)) {
        return FALSE;
    }

    /*
     * If the parameter is out or inout, make it a Java array of the
     * appropriate type
     */

    if (IDL_PARAM_DCL(param).attr != IDL_PARAM_IN) {
        fputs("[]", FILENAME(state));
    }

    /*
     * If the parameter is an array make it a Java array
     */
    if (IDL_tree_property_get(IDL_PARAM_DCL(param).simple_declarator, "array"))
        fputs("[]", FILENAME(state));

    /*
     * Put in name of parameter 
     */

    fputc(' ', FILENAME(state));

    fputs(subscriptIdentifier(state, 
                              IDL_IDENT(IDL_PARAM_DCL(param).simple_declarator).str), 
          FILENAME(state));
    return TRUE;
}
Exemple #29
0
void Board_load_board(int board_type)
{
   FILE *fl;
   int i, len1 = 0, len2 = 0;
   char *tmp1 = 0, *tmp2 = 0;


   if (!(fl = fopen(FILENAME(board_type), "rb"))) {
	perror("Error reading board");
	return;
   }

  fread(&(num_of_msgs[board_type]), sizeof(int), 1, fl);
  if (num_of_msgs[board_type] < 1 || num_of_msgs[board_type] > MAX_BOARD_MESSAGES) {
	log("Board file corrupt.  Resetting.");
	Board_reset_board(board_type);
	return;
  }

  for (i = 0; i < num_of_msgs[board_type]; i++) {
	fread(&(msg_index[board_type][i]),sizeof(struct board_msginfo),1,fl);
	if (!(len1 = msg_index[board_type][i].heading_len)) {
		log("Board file corrupt!  Resetting.");
		Board_reset_board(board_type);
		return;
	}

	if (!(tmp1 = (char *)malloc(sizeof(char) * len1))) {
		log("Error - malloc failed for board header");
		exit(1);
	}

	fread(tmp1, sizeof(char), len1, fl);
	MSG_HEADING(board_type, i) = tmp1;

	if ((len2 = msg_index[board_type][i].message_len)) {
		if ((MSG_SLOTNUM(board_type, i) = find_slot()) == -1) {
			log("Out of slots booting board!  Resetting..");
			Board_reset_board(board_type);
			return;
		}
		if (!(tmp2 = (char *)malloc(sizeof(char) * len2))) {
			log("Error - malloc failed for board text");
			exit(1);
		}
		fread(tmp2, sizeof(char), len2, fl);
		msg_storage[MSG_SLOTNUM(board_type, i)] = tmp2;
	}
   }

   fclose(fl);
}
Exemple #30
0
bool XMLFileReader::Parse(XMLTagHandler *baseHandler,
                          const char *fname)
{
   FILE *fp = fopen(FILENAME(fname), "rb");
   if (!fp || ferror(fp)) {
      const char *formatStr = _("Could not open file: \"%s\"");
      if (mErrorStr)
         delete[] mErrorStr;
      mErrorStr = new char[strlen(fname) + strlen(formatStr) + 10];
      sprintf(mErrorStr, formatStr, fname);
      return false;
   }

   mBaseHandler = baseHandler;
   mHandler[0] = NULL;

   const size_t bufferSize = 16384;
   char buffer[16384];
   int done = 0;
   do {
      size_t len = fread(buffer, 1, bufferSize, fp);
      done = (len < bufferSize);
      if (!XML_Parse(mParser, buffer, len, done)) {
         const char *formatStr = _("Error: %s at line %d");
         const char *errorStr = XML_ErrorString(XML_GetErrorCode(mParser));
         if (mErrorStr)
            delete[] mErrorStr;
         mErrorStr = new char[strlen(errorStr) + strlen(formatStr) + 10];
         sprintf(mErrorStr, formatStr,
                 errorStr, XML_GetCurrentLineNumber(mParser));
         fclose(fp);
         return false;
      }
   } while (!done);

   fclose(fp);

   // Even though there were no parse errors, we only succeed if
   // the first-level handler actually got called, and didn't
   // return false.
   if (mHandler[0])
      return true;
   else {
      const char *errorStr = _("Unable to open project file.");
      if (mErrorStr)
         delete[] mErrorStr;
      mErrorStr = new char[strlen(errorStr)+1];
      strcpy(mErrorStr, errorStr);

      return false;
   }
}