- wxMimeTextFile appoutfile, mimeoutfile;
- wxString sHome = wxGetHomeDir();
- wxString sTmp = wxT(".kde/share/mimelnk/");
- wxString sMime = m_aTypes[index];
- CheckKDEDirsExist(sHome, sTmp + sMime.BeforeFirst(wxT('/')) );
- sTmp = sHome + wxT('/') + sTmp + sMime + wxT(".kdelnk");
-
- bool bTemp;
- bool bMimeExists = mimeoutfile.Open(sTmp);
- if (!bMimeExists)
- {
- bTemp = mimeoutfile.Create(sTmp);
- // some unknown error eg out of disk space
- if (!bTemp)
- return false;
- }
-
- sTmp = wxT(".kde/share/applnk/");
- CheckKDEDirsExist(sHome, sTmp + sMime.AfterFirst(wxT('/')) );
- sTmp = sHome + wxT('/') + sTmp + sMime.AfterFirst(wxT('/')) + wxT(".kdelnk");
-
- bool bAppExists;
- bAppExists = appoutfile.Open(sTmp);
- if (!bAppExists)
- {
- bTemp = appoutfile.Create(sTmp);
- // some unknown error eg out of disk space
- if (!bTemp)
- return false;
- }
-
- // fixed data; write if new file
- if (!bMimeExists)
- {
- mimeoutfile.AddLine(wxT("#KDE Config File"));
- mimeoutfile.AddLine(wxT("[KDE Desktop Entry]"));
- mimeoutfile.AddLine(wxT("Version=1.0"));
- mimeoutfile.AddLine(wxT("Type=MimeType"));
- mimeoutfile.AddLine(wxT("MimeType=") + sMime);
- }
-
- if (!bAppExists)
- {
- mimeoutfile.AddLine(wxT("#KDE Config File"));
- mimeoutfile.AddLine(wxT("[KDE Desktop Entry]"));
- appoutfile.AddLine(wxT("Version=1.0"));
- appoutfile.AddLine(wxT("Type=Application"));
- appoutfile.AddLine(wxT("MimeType=") + sMime + wxT(';'));
- }
-
- // variable data
- // ignore locale
- mimeoutfile.CommentLine(wxT("Comment="));
- if (!delete_index)
- mimeoutfile.AddLine(wxT("Comment=") + m_aDescriptions[index]);
- appoutfile.CommentLine(wxT("Name="));
- if (!delete_index)
- appoutfile.AddLine(wxT("Comment=") + m_aDescriptions[index]);
-
- sTmp = m_aIcons[index];
- // we can either give the full path, or the shortfilename if its in
- // one of the directories we search
- mimeoutfile.CommentLine(wxT("Icon=") );
- if (!delete_index)
- mimeoutfile.AddLine(wxT("Icon=") + sTmp );
- appoutfile.CommentLine(wxT("Icon=") );
- if (!delete_index)
- appoutfile.AddLine(wxT("Icon=") + sTmp );
-
- sTmp = wxT(" ") + m_aExtensions[index];
-
- wxStringTokenizer tokenizer(sTmp, wxT(" "));
- sTmp = wxT("Patterns=");
- mimeoutfile.CommentLine(sTmp);
- while ( tokenizer.HasMoreTokens() )
- {
- // holds an extension; need to change it to *.ext;
- wxString e = wxT("*.") + tokenizer.GetNextToken() + wxT(";");
- sTmp += e;
- }
-
- if (!delete_index)
- mimeoutfile.AddLine(sTmp);
-
- wxMimeTypeCommands * entries = m_aEntries[index];
- // if we don't find open just have an empty string ... FIX this
- sTmp = entries->GetCommandForVerb(wxT("open"));
- sTmp.Replace( wxT("%s"), wxT("%f") );