picasa_albums_indexer.h revision eb525c5499e34cc9c4b825d6d9e75bb07cc06ace
1// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_
6#define CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_
7
8#include <map>
9#include <set>
10#include <string>
11
12#include "base/files/file_path.h"
13
14namespace picasa {
15
16// Defined outside of class because used by IPC messages.
17typedef std::set<base::FilePath> AlbumImages;
18typedef std::set<std::string> AlbumUUIDSet;
19typedef std::map<std::string, AlbumImages> AlbumImagesMap;
20
21// Parses a series of INI files and builds up the set of files contained within
22// the albums passed in through |album_uuids|.
23//
24// Each INI file only describes the images contained within a single directory.
25// To build the contents of all the albums, we read in all the INI files
26// in all the Picasa folders.
27//
28// The INI albums also contain ".album*" sections describing the albums that
29// have pictures in the same directory as the INI. However, we use the PMP
30// database as the authoritative source on Album metadata, so we ignore those
31// sections. The PMP derived |album_uuids| are passed in by the constructor.
32//
33// Example INI File:
34//
35// [.album:e66fb059001aabcc69b262b7009fad90]
36// name=CustomAlbum1
37// token=e66fb059001aabcc69b262b7009fad90
38// date=2013-03-15T14:53:21-07:00
39// [InBoth.jpg]
40// albums=e66fb059001aabcc69b262b7009fad90,18cb2df48aaa98e1c276b45cfcd81c95
41// [.album:18cb2df48aaa98e1c276b45cfcd81c95]
42// name=CustomAlbum1
43// token=18cb2df48aaa98e1c276b45cfcd81c95
44// date=2013-04-01T16:37:34-07:00
45// [InFirst.jpg]
46// albums=e66fb059001aabcc69b262b7009fad90
47// [InSecond.jpg]
48// albums=18cb2df48aaa98e1c276b45cfcd81c95
49class PicasaAlbumsIndexer {
50 public:
51  explicit PicasaAlbumsIndexer(const AlbumUUIDSet& album_uuids);
52  ~PicasaAlbumsIndexer();
53
54  // This method should be called once for each Folder in the PMP database.
55  void ParseFolderINI(const base::FilePath& folder_path,
56                      const std::string& ini_contents);
57
58  const AlbumImagesMap& albums_images() const { return albums_images_; }
59
60 private:
61  AlbumImagesMap albums_images_;
62
63  DISALLOW_COPY_AND_ASSIGN(PicasaAlbumsIndexer);
64};
65
66}  // namespace picasa
67
68#endif  // CHROME_UTILITY_MEDIA_GALLERIES_PICASA_ALBUMS_INDEXER_H_
69