• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "chrome/common/media_galleries/picasa_types.h"
6 
7 #include "base/logging.h"
8 #include "chrome/common/media_galleries/pmp_constants.h"
9 
10 namespace picasa {
11 
12 namespace {
13 
OpenFile(const base::FilePath & directory_path,const std::string & suffix)14 base::File OpenFile(const base::FilePath& directory_path,
15                     const std::string& suffix) {
16   base::FilePath path = directory_path.Append(base::FilePath::FromUTF8Unsafe(
17       std::string(kPicasaAlbumTableName) + "_" + suffix));
18   return base::File(path, base::File::FLAG_OPEN | base::File::FLAG_READ);
19 }
20 
OpenColumnFile(const base::FilePath & directory_path,const std::string & column_name)21 base::File OpenColumnFile(const base::FilePath& directory_path,
22                           const std::string& column_name) {
23   return OpenFile(directory_path, column_name + "." + kPmpExtension);
24 }
25 
26 }  // namespace
27 
28 const char kPicasaDatabaseDirName[] = "db3";
29 const char kPicasaTempDirName[] = "tmp";
30 
31 const char kPicasaAlbumTableName[] = "albumdata";
32 const char kAlbumTokenPrefix[] = "]album:";
33 const char kPicasaINIFilename[] = ".picasa.ini";
34 
35 const uint32 kAlbumCategoryAlbum = 0;
36 const uint32 kAlbumCategoryFolder = 2;
37 const uint32 kAlbumCategoryInvalid = 0xffff;  // Sentinel value.
38 
AlbumInfo()39 AlbumInfo::AlbumInfo() {
40 }
41 
AlbumInfo(const std::string & name,const base::Time & timestamp,const std::string & uid,const base::FilePath & path)42 AlbumInfo::AlbumInfo(const std::string& name, const base::Time& timestamp,
43                      const std::string& uid, const base::FilePath& path)
44     : name(name),
45       timestamp(timestamp),
46       uid(uid),
47       path(path) {
48 }
49 
~AlbumInfo()50 AlbumInfo::~AlbumInfo() {
51 }
52 
AlbumTableFiles()53 AlbumTableFiles::AlbumTableFiles() {
54 }
55 
AlbumTableFiles(const base::FilePath & directory_path)56 AlbumTableFiles::AlbumTableFiles(const base::FilePath& directory_path)
57     : indicator_file(OpenFile(directory_path, "0")),
58       category_file(OpenColumnFile(directory_path, "category")),
59       date_file(OpenColumnFile(directory_path, "date")),
60       filename_file(OpenColumnFile(directory_path, "filename")),
61       name_file(OpenColumnFile(directory_path, "name")),
62       token_file(OpenColumnFile(directory_path, "token")),
63       uid_file(OpenColumnFile(directory_path, "uid")) {
64 }
65 
~AlbumTableFiles()66 AlbumTableFiles::~AlbumTableFiles() {
67 }
68 
AlbumTableFiles(RValue other)69 AlbumTableFiles::AlbumTableFiles(RValue other)
70     : indicator_file(other.object->indicator_file.Pass()),
71       category_file(other.object->category_file.Pass()),
72       date_file(other.object->date_file.Pass()),
73       filename_file(other.object->filename_file.Pass()),
74       name_file(other.object->name_file.Pass()),
75       token_file(other.object->token_file.Pass()),
76       uid_file(other.object->uid_file.Pass()) {
77 }
78 
operator =(RValue other)79 AlbumTableFiles& AlbumTableFiles::operator=(RValue other) {
80   if (this != other.object) {
81     indicator_file = other.object->indicator_file.Pass();
82     category_file = other.object->category_file.Pass();
83     date_file = other.object->date_file.Pass();
84     filename_file = other.object->filename_file.Pass();
85     name_file = other.object->name_file.Pass();
86     token_file = other.object->token_file.Pass();
87     uid_file = other.object->uid_file.Pass();
88   }
89   return *this;
90 }
91 
AlbumTableFilesForTransit()92 AlbumTableFilesForTransit::AlbumTableFilesForTransit()
93     : indicator_file(IPC::InvalidPlatformFileForTransit()),
94       category_file(IPC::InvalidPlatformFileForTransit()),
95       date_file(IPC::InvalidPlatformFileForTransit()),
96       filename_file(IPC::InvalidPlatformFileForTransit()),
97       name_file(IPC::InvalidPlatformFileForTransit()),
98       token_file(IPC::InvalidPlatformFileForTransit()),
99       uid_file(IPC::InvalidPlatformFileForTransit()) {
100 }
101 
102 }  // namespace picasa
103