zeroconf/zeroconfsharing/contactinfo.cpp
changeset 21 ff5174af067c
equal deleted inserted replaced
14:da856f45b798 21:ff5174af067c
       
     1 /*
       
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 #include <contactinfo.h>
       
    18 
       
    19 _LIT8(KPath,"C:\\Data\\ZeroConf\\");
       
    20 
       
    21 const TUint MaxLength= 255;
       
    22 
       
    23 
       
    24 CContactInfo* CContactInfo::NewL()
       
    25     {
       
    26     CContactInfo* self = CContactInfo::NewLC();
       
    27     CleanupStack::Pop(self);
       
    28     return self;
       
    29     }
       
    30         
       
    31 CContactInfo* CContactInfo::NewLC()
       
    32     {
       
    33     CContactInfo* self = new (ELeave) CContactInfo();
       
    34     CleanupStack::PushL(self);
       
    35     self->ConstructL();
       
    36     return self;
       
    37     }
       
    38         
       
    39 CContactInfo::CContactInfo()
       
    40     {
       
    41     
       
    42     }
       
    43     
       
    44 void CContactInfo::ConstructL()
       
    45     {
       
    46     iFs.Connect();
       
    47     }
       
    48         
       
    49 CContactInfo::~CContactInfo()
       
    50     {
       
    51     iFs.Close();
       
    52     iContact.Close();
       
    53     iCurrentlyPlaying.Close();
       
    54     iContactDirectory.Close();
       
    55     iFileUrl.Close(); 
       
    56     iIconPath.Close();
       
    57     iBaseUrl.Close();
       
    58     iFileUrl.Close();
       
    59     iImgFile.Close();
       
    60     iMusicFile.Close();
       
    61     iVideoFile.Close();
       
    62     iFilePath.Close();
       
    63     }
       
    64         
       
    65 const TDesC8& CContactInfo::ContactName()const
       
    66     {
       
    67     return iContact;
       
    68     }
       
    69  
       
    70 void CContactInfo::SetContactName(const TDesC8& aContactName)
       
    71     {
       
    72     iContact.Close();
       
    73     iContact.Create(aContactName);
       
    74     }
       
    75         
       
    76 const TDesC8& CContactInfo::CurrentlyPlaying()const
       
    77     {
       
    78     return iCurrentlyPlaying;
       
    79     }
       
    80        
       
    81 void CContactInfo::SetCurrentlyPlaying(const TDesC8& aCurrentlyPlaying)
       
    82     {
       
    83     iCurrentlyPlaying.Close();
       
    84     iCurrentlyPlaying.Create(aCurrentlyPlaying);
       
    85     }
       
    86 
       
    87 const TDesC8& CContactInfo::Status()const
       
    88     {
       
    89     return iStatus;
       
    90     }
       
    91        
       
    92 void CContactInfo::SetStatus(const TDesC8& aStatus)
       
    93     {
       
    94     iStatus.Close();
       
    95     iStatus.Create(aStatus);
       
    96     }
       
    97         
       
    98 void CContactInfo::SetContactDirectory()
       
    99     {
       
   100     iContactDirectory.Close();
       
   101     
       
   102     _LIT8(KTrailingSlash,"\\");
       
   103     TBuf8 <255> path(KPath);
       
   104     iContactDirectory.Create(path,MaxLength);
       
   105     iContactDirectory.Append(iContact);
       
   106     iContactDirectory.Append(KTrailingSlash);
       
   107     
       
   108     RBuf folder;
       
   109     folder.Create(iContactDirectory.Length());
       
   110     
       
   111     folder.Copy(iContactDirectory);
       
   112     
       
   113     if(!BaflUtils::FolderExists(iFs,folder))
       
   114         {
       
   115         iFs.MkDirAll(folder);
       
   116         }
       
   117     }
       
   118 const TDesC8& CContactInfo::ContactDirectory()
       
   119     {
       
   120     return iContactDirectory;
       
   121     }
       
   122 
       
   123 const TDesC8& CContactInfo::ImgFileName()
       
   124     {
       
   125     _LIT8(KImageFile,"ImageFile.txt");
       
   126     iImgFile.Close();
       
   127     iImgFile.Create(iContactDirectory,MaxLength);
       
   128     iImgFile.Append(KImageFile);
       
   129     return iImgFile;
       
   130     }
       
   131 
       
   132 const TDesC8& CContactInfo::MusicFileName()
       
   133     {
       
   134     _LIT8(KMusicFile,"MusicFile.txt");
       
   135     iMusicFile.Close();
       
   136     iMusicFile.Create(iContactDirectory,MaxLength);
       
   137     iMusicFile.Append(KMusicFile);
       
   138     return iMusicFile;
       
   139     }
       
   140 
       
   141 const TDesC8& CContactInfo::VideoFileName()
       
   142     {
       
   143     _LIT8(KVideoFile,"VideoFile.txt");
       
   144     iVideoFile.Close();
       
   145     iVideoFile.Create(iContactDirectory,MaxLength);
       
   146     iVideoFile.Append(KVideoFile);
       
   147     return iVideoFile;
       
   148     }
       
   149 
       
   150 void CContactInfo::SetBaseUrl(const TDesC8& aBaseUrl)
       
   151     {
       
   152     iBaseUrl.Close();
       
   153     iBaseUrl.CreateL(aBaseUrl);
       
   154     }
       
   155 const TDesC8& CContactInfo::BaseUrl()const
       
   156     {
       
   157     return iBaseUrl;
       
   158     }
       
   159 
       
   160 const  TDesC8& CContactInfo::FileUrl(const TDesC8& aFileName)
       
   161     {    
       
   162     iFileUrl.Close();    
       
   163     iFileUrl.Create(iBaseUrl,MaxLength);
       
   164     iFileUrl.Append(aFileName);
       
   165     return iFileUrl;
       
   166     }
       
   167 
       
   168 TBool CContactInfo::HasBeenDownloadedL(const TDesC8& aFileName)
       
   169     {
       
   170     iFileUrl.Close(); 
       
   171     RBuf8 contactDir;
       
   172     
       
   173     contactDir.Create(iContactDirectory.Length());
       
   174     contactDir.Copy(iContactDirectory);
       
   175     
       
   176     iFileUrl.Create(contactDir,MaxLength);
       
   177     iFileUrl.Copy(contactDir);
       
   178     iFileUrl.Append(aFileName);
       
   179     
       
   180     RBuf fileName;
       
   181     fileName.CreateL(iFileUrl.Length());
       
   182     fileName.Copy(iFileUrl);
       
   183     
       
   184     
       
   185     if(BaflUtils::FileExists(iFs,fileName))
       
   186         return ETrue;
       
   187     else
       
   188         return EFalse;
       
   189     }
       
   190 
       
   191 
       
   192 const TDesC8& CContactInfo::IconFilePath(const TDesC8& aIconFile)
       
   193     {
       
   194     iIconPath.Close();
       
   195     iIconPath.Create(iContactDirectory,MaxLength);
       
   196     iIconPath.Append(aIconFile);
       
   197     return iIconPath;
       
   198     }
       
   199 const TDesC8& CContactInfo::IconPath()
       
   200     {
       
   201     return iIconPath;
       
   202     }
       
   203 
       
   204 const TDesC8& CContactInfo::FileListPath(const TDesC8& aFileListName)
       
   205     {
       
   206     iFileListPath.Close();
       
   207     iFileListPath.Create(iContactDirectory,MaxLength);
       
   208     iFileListPath.Append(aFileListName);
       
   209     return iFileListPath;
       
   210     }
       
   211         
       
   212 const TDesC8& CContactInfo::FilePath(const TDesC8& aFileName)
       
   213     {
       
   214     iFilePath.Close();
       
   215     iFilePath.Create(iContactDirectory,MaxLength);
       
   216     iFilePath.Append(aFileName);
       
   217     return iFilePath;
       
   218     }
       
   219 
       
   220 
       
   221 
       
   222 void CContactInfo::StoreContactDirectory(const TDesC8& aContactDirectory)
       
   223     {
       
   224     iContactDirectory.Close();
       
   225     iContactDirectory.Create(aContactDirectory);
       
   226     }
       
   227