~ubuntu-branches/ubuntu/lucid/desktop-file-utils/lucid

« back to all changes in this revision

Viewing changes to src/validate.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-18 23:33:28 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070218233328-rjmdgiikbaq5u2my
Tags: 0.12-0ubuntu1
* New upstream version:
  - improves category validation code to not catch false positives
  - make category validation code non-fatal
  - fix mem leaks and double frees
* debian/control:
  - use Desktop Team for Maintainer

Show diffs side-by-side

added added

removed removed

Lines of Context:
148
148
static void
149
149
validate_categories (const char *value, const char *key, const char *locale, const char *filename, GnomeDesktopFile *df)
150
150
{
151
 
  /* Category list from Desktop Menu Specification version 1.0-draft4 */
152
 
  const char *categories_keys[] = {
153
 
    "Core", "Development", "Building", "Debugger", "IDE", "GUIDesigner",
154
 
    "Profiling", "RevisionControl", "Translation", "Office", "Calendar",
155
 
    "ContactManagement", "Database", "Dictionary", "Chart", "Email",
156
 
    "Finance", "FlowChart", "PDA", "ProjectManagement", "Presentation",
157
 
    "Spreadsheet", "WordProcessor", "Graphics", "2DGraphics", "VectorGraphics",
158
 
    "RasterGraphics", "3DGraphics", "Scanning", "OCR", "Photography",
159
 
    "Viewer", "Settings", "DesktopSettings", "HardwareSettings",
160
 
    "PackageManager", "Network", "Dialup", "InstantMessaging", "IRCClient",
161
 
    "FileTransfer", "HamRadio", "News", "P2P", "RemoteAccess", "Telephony",
162
 
    "WebBrowser", "WebDevelopment", "AudioVideo", "Audio", "Midi", "Mixer",
163
 
    "Sequencer", "Tuner", "Video", "TV", "AudioVideoEditing", "Player",
164
 
    "Recorder", "DiscBurning", "Game", "ActionGame", "AdventureGame",
165
 
    "ArcadeGame", "BoardGame", "BlocksGame", "CardGame", "KidsGame",
166
 
    "LogicGame", "RolePlaying", "Simulation", "SportsGame", "StrategyGame",
167
 
    "Education", "Art", "Construction", "Music", "Languages", "Science",
168
 
    "Astronomy", "Biology", "Chemistry", "Geology", "Math", "MedicalSoftware",
169
 
    "Physics", "Teaching", "Amusement", "Applet", "Archiving", "Electronics",
170
 
    "Emulator", "Engineering", "FileManager", "Shell", "ScreenSaver",
171
 
    "TeminalEmulator", "TrayIcon", "System", "Filesystem", "Monitor",
172
 
    "Security", "Utility", "Accessibility", "Calculator", "Clock",
173
 
    "TextEditor", "KDE", "GNOME", "GTK", "Qt", "Motif", "Java",
174
 
    "ConsoleOnly", NULL
 
151
  #define MAIN_CATEGORIES \
 
152
    "AudioVideo", "Audio", "Video", "Development", "Education", "Game", \
 
153
    "Graphics", "Network", "Office", "Settings", "System", "Utility"
 
154
 
 
155
  #define ADDITIONAL_CATEGORIES \
 
156
    "Building", "Debugger", "IDE", "GUIDesigner", "Profiling", \
 
157
    "RevisionControl", "Translation", "Calendar", "ContactManagement", \
 
158
    "Database", "Dictionary", "Chart", "Email", "Finance", "FlowChart", "PDA", \
 
159
    "ProjectManagement", "Presentation", "Spreadsheet", "WordProcessor", \
 
160
    "2DGraphics", "VectorGraphics", "RasterGraphics", "3DGraphics", \
 
161
    "Scanning", "OCR", "Photography", "Viewer", "DesktopSettings", \
 
162
    "HardwareSettings", "PackageManager", "Dialup", "InstantMessaging", \
 
163
    "IRCClient", "FileTransfer", "HamRadio", "News", "P2P", "RemoteAccess", \
 
164
    "Telephony", "WebBrowser", "WebDevelopment", "Midi", "Mixer", "Sequencer", \
 
165
    "Tuner", "TV", "AudioVideoEditing", "Player", "Recorder", "DiscBurning", \
 
166
    "ActionGame", "AdventureGame", "ArcadeGame", "BoardGame", "BlocksGame", \
 
167
    "CardGame", "KidsGame", "LogicGame", "RolePlaying", "Simulation", \
 
168
    "SportsGame", "StrategyGame", "Art", "Construction", "Music", "Languages", \
 
169
    "Science", "Astronomy", "Biology", "Chemistry", "Geology", "Math", \
 
170
    "MedicalSoftware", "Physics", "Amusement", "Archiving", "Electronics", \
 
171
    "Emulator", "Engineering", "FileManager", "TerminalEmulator", \
 
172
    "Filesystem", "Monitor", "Security", "Accessibility", "Calculator", \
 
173
    "Clock", "TextEditor", "Core", "KDE", "GNOME", "GTK", "Qt", "Motif", \
 
174
    "Java", "ConsoleOnly"
 
175
 
 
176
  #define RESERVED_CATEGORIES \
 
177
    "Screensaver", "TrayIcon", "Applet", "Shell"
 
178
 
 
179
  /* Category list from Desktop Menu Specification version 1.0 */
 
180
  static const char *categories_keys[] = {
 
181
    MAIN_CATEGORIES, ADDITIONAL_CATEGORIES, RESERVED_CATEGORIES, NULL
175
182
  };
176
183
  char **vals;
177
184
  int i;
202
209
    {
203
210
      int j = 0;
204
211
 
 
212
      if (strncmp ("X-", vals[i], 2) == 0)
 
213
        {
 
214
          i++;
 
215
          continue;
 
216
        }
 
217
 
205
218
      while (categories_keys[j])
206
219
        {
207
220
          if (g_ascii_strcasecmp (vals[i], categories_keys[j]) == 0)
208
221
            {
209
222
              if (strcmp (vals[i], categories_keys[j]) != 0)
210
223
                {
211
 
                  print_fatal (filename, "%s values are case sensitive (should be \"%s\" instead of \"%s\")\n",
 
224
                  print_warning (filename, "%s values are case sensitive (should be \"%s\" instead of \"%s\")\n",
212
225
                               key, categories_keys[j], vals[i]);
213
226
                }
214
 
              break;
 
227
 
 
228
              break;
215
229
            }
216
230
          ++j;
217
231
        }
220
234
        {
221
235
          char *valid_categories;
222
236
 
223
 
          valid_categories = g_strjoinv ("\", \"", (gchar **) categories_keys);
224
 
          print_fatal (filename, "%s values must be one of \"%s\" (found \"%s\")\n",
225
 
                       key, valid_categories, vals[i]);
 
237
          if ((g_ascii_strcasecmp (vals[i], "Application") == 0) ||
 
238
              (g_ascii_strcasecmp (vals[i], "Applications") == 0))
 
239
          {
 
240
            valid_categories = g_strjoin ("\", \"", MAIN_CATEGORIES, NULL);
 
241
            print_warning (filename, "The '%s' category is not defined by the desktop entry specification.  Please use one of \"%s\" instead\n",
 
242
                           vals[i], valid_categories);
 
243
          } else {
 
244
            valid_categories = g_strjoinv ("\", \"", (gchar **) categories_keys);
 
245
            print_warning (filename, "%s values must be one of \"%s\" (found \"%s\")\n",
 
246
                           key, valid_categories, vals[i]);
 
247
          }
226
248
          g_free (valid_categories);
227
249
        }
228
250
      ++i;
469
491
  { "DocPath", validate_string },                 /* 0.9.4: within KDE only */
470
492
  { "Extensions", validate_string, TRUE },        /* 0.9.3: deprecated */
471
493
  { "InitialPreference", validate_string },       /* 0.9.4: within KDE only */
472
 
  { "Keywords", validate_string },                /* 0.9.4: within KDE only */
 
494
  { "Keywords", validate_localestring },          /* 0.9.4: within KDE only */
473
495
  { "MapNotify", validate_string, TRUE },         /* 0.9.3: deprecated */
474
496
  { "Protocols", validate_string, TRUE },         /* 0.9.3: deprecated */
475
497
  { "ServiceTypes", validate_string },            /* 0.9.4: within KDE only */