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
10namespace picasa {
11
12namespace {
13
14base::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
21base::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
28const char kPicasaDatabaseDirName[] = "db3";
29const char kPicasaTempDirName[] = "tmp";
30
31const char kPicasaAlbumTableName[] = "albumdata";
32const char kAlbumTokenPrefix[] = "]album:";
33const char kPicasaINIFilename[] = ".picasa.ini";
34
35const uint32 kAlbumCategoryAlbum = 0;
36const uint32 kAlbumCategoryFolder = 2;
37const uint32 kAlbumCategoryInvalid = 0xffff;  // Sentinel value.
38
39AlbumInfo::AlbumInfo() {
40}
41
42AlbumInfo::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
50AlbumInfo::~AlbumInfo() {
51}
52
53AlbumTableFiles::AlbumTableFiles() {
54}
55
56AlbumTableFiles::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
66AlbumTableFiles::~AlbumTableFiles() {
67}
68
69AlbumTableFiles::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
79AlbumTableFiles& 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
92AlbumTableFilesForTransit::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