supl/locationsuplfw/settingsapi/src/epos_csettingsdatabasehandler.cpp
branchRCL_3
changeset 44 2b4ea9893b66
parent 4 42de37ce7ce4
child 45 6b6920c56e2f
equal deleted inserted replaced
42:02ba3f1733c6 44:2b4ea9893b66
    52 const TInt KPskTlsUsed = 4;
    52 const TInt KPskTlsUsed = 4;
    53 const TInt KServerEnabled = 8;
    53 const TInt KServerEnabled = 8;
    54 const TInt KSimChangeRemove = 32;
    54 const TInt KSimChangeRemove = 32;
    55 const TInt KUsageInHomeNw = 64;
    55 const TInt KUsageInHomeNw = 64;
    56 const TInt KEditable = 128;
    56 const TInt KEditable = 128;
       
    57 const TInt KProductConfigured= 256;
    57 
    58 
    58 //values used to set and retrieve major and minor version numbers from a single int
    59 //values used to set and retrieve major and minor version numbers from a single int
    59 const TInt KVersionMinorMask = 255;
    60 const TInt KVersionMinorMask = 255;
    60 const TInt KVersionMajorMask = 8;
    61 const TInt KVersionMajorMask = 8;
    61 
    62 
   124 _LIT(KColTriggerNotificationStatus, "NotificationStatus");
   125 _LIT(KColTriggerNotificationStatus, "NotificationStatus");
   125 _LIT(KColTriggerType,"TriggerType");
   126 _LIT(KColTriggerType,"TriggerType");
   126 _LIT(KColRequestType,"RequestType");
   127 _LIT(KColRequestType,"RequestType");
   127 _LIT(KColOutstandingTrigger,"OutstandingTrigger");      
   128 _LIT(KColOutstandingTrigger,"OutstandingTrigger");      
   128 _LIT(KColInterval,"Interval");
   129 _LIT(KColInterval,"Interval");
       
   130 _LIT(KColEndTime,"EndTime");
   129 
   131 
   130 _LIT(KColServerId,"ServerId");
   132 _LIT(KColServerId,"ServerId");
   131 _LIT(KColIap1,"Iap1");
   133 _LIT(KColIap1,"Iap1");
   132 _LIT(KColIap2,"Iap2");
   134 _LIT(KColIap2,"Iap2");
   133 _LIT(KColServerAddress,"ServerAddress");
   135 _LIT(KColServerAddress,"ServerAddress");
   152 //
   154 //
   153 // Destructor method
   155 // Destructor method
   154 // ---------------------------------------------------------------------------
   156 // ---------------------------------------------------------------------------
   155 CSettingsDatabaseHandler::~CSettingsDatabaseHandler()
   157 CSettingsDatabaseHandler::~CSettingsDatabaseHandler()
   156     {
   158     {
   157     if(iSettingsRep)
   159 				delete iSettingsRep;
   158         {
   160 				iSettingsRep = NULL;
   159         delete iSettingsRep;
   161 				
   160         iSettingsRep = NULL;
   162 				delete iSettingsNotifierRep;
   161         }    
   163 				iSettingsNotifierRep = NULL;
   162     if(iSettingsNotifierRep)
   164 				
   163         {
   165 				Close();
   164         delete iSettingsNotifierRep;
   166 				
   165         iSettingsNotifierRep = NULL;
   167 				LogQuery(_L("Deleted Settings DB Handle CLosed"));
   166         }
   168 				
   167     iDb.Close();
       
   168     LogQuery(_L("Deleted Settings DB Handle CLosed"));
       
   169     }
   169     }
   170 
   170 
   171 // ---------------------------------------------------------------------------
   171 // ---------------------------------------------------------------------------
   172 // CSettingsDatabaseHandler::ConstructL()
   172 // CSettingsDatabaseHandler::ConstructL()
   173 //
   173 //
   271     PrintErrorMessage(dbPath,err,3);
   271     PrintErrorMessage(dbPath,err,3);
   272     User::LeaveIfError(err);
   272     User::LeaveIfError(err);
   273     }
   273     }
   274  
   274  
   275 // ---------------------------------------------------------------------------
   275 // ---------------------------------------------------------------------------
   276 // CSettingsDatabaseHandler::RemoveDb()
       
   277 //
       
   278 // 
       
   279 // ---------------------------------------------------------------------------
       
   280 TInt CSettingsDatabaseHandler::RemoveDb()
       
   281     {
       
   282     Close();
       
   283    // iDbs.DeleteDatabase(KWordDatabase,KSecureUid);
       
   284     return KErrNone;
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // CSettingsDatabaseHandler::Close()
   276 // CSettingsDatabaseHandler::Close()
   289 //
   277 //
   290 // Close the database.
   278 // Close the database.
   291 // ---------------------------------------------------------------------------
   279 // ---------------------------------------------------------------------------
   292 TInt CSettingsDatabaseHandler::Close()
   280 TInt CSettingsDatabaseHandler::Close()
   448     TTime  timeLastUse;
   436     TTime  timeLastUse;
   449     TTime  timeLastTried;
   437     TTime  timeLastTried;
   450     
   438     
   451     TInt32  netInfoLastUse = 0;
   439     TInt32  netInfoLastUse = 0;
   452     TInt32  netInfoLastSucess = 0;
   440     TInt32  netInfoLastSucess = 0;
   453     TBool   serverEnabled,simChangeRemove,usageInHomeNw,editable;
   441     TBool   serverEnabled,simChangeRemove,usageInHomeNw,editable,prodConfig;
   454     
   442     
   455     TInt ret = 0;
   443     TInt ret = aServParamValues->Get(slpId,SLPAddress->Des(),IAPName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable);
   456     ret = aServParamValues->Get(slpId,SLPAddress->Des(),IAPName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable);
   444     					 aServParamValues->GetServerConfigurationType(prodConfig); 
       
   445     
   457     if(ret == KErrNotFound)
   446     if(ret == KErrNotFound)
   458         {
   447         {
   459         CleanupStack::PopAndDestroy(3); //SLPAddress,IAPName,manuName
   448         CleanupStack::PopAndDestroy(3); //SLPAddress,IAPName,manuName
   460         aSlpId = -1;
   449         aSlpId = -1;
   461         PrintErrorMessage(_L(""),KErrNotFound,8);
   450         PrintErrorMessage(_L(""),KErrNotFound,8);
   512         OtherProperties |= KUsageInHomeNw;
   501         OtherProperties |= KUsageInHomeNw;
   513         }
   502         }
   514     if(editable)
   503     if(editable)
   515         {
   504         {
   516         OtherProperties |= KEditable;
   505         OtherProperties |= KEditable;
       
   506         }
       
   507     if(prodConfig)
       
   508         {
       
   509         OtherProperties |= KProductConfigured;
   517         }
   510         }
   518     
   511     
   519     TBuf<KMaxHSLPAddrLen> tempBuf;
   512     TBuf<KMaxHSLPAddrLen> tempBuf;
   520     TBuf<KMaxIAPLen> tempIapBuf;
   513     TBuf<KMaxIAPLen> tempIapBuf;
   521     tempBuf.Copy(*SLPAddress);
   514     tempBuf.Copy(*SLPAddress);
   847     TInt64 slpId;
   840     TInt64 slpId;
   848     HBufC* SLPAddress = HBufC::NewLC( KMaxHSLPAddrLen);
   841     HBufC* SLPAddress = HBufC::NewLC( KMaxHSLPAddrLen);
   849     
   842     
   850     HBufC* IAPName = HBufC::NewLC( KMaxIAPLen);
   843     HBufC* IAPName = HBufC::NewLC( KMaxIAPLen);
   851     TBool  serverEnabled,simChangeRemove,usageInHomeNw,editable;
   844     TBool  serverEnabled,simChangeRemove,usageInHomeNw,editable;
   852 
   845     
   853 
   846     TInt ret = aParamValues->Get(slpId,SLPAddress->Des(),IAPName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable);
   854     TInt ret = 0;
       
   855     ret = aParamValues->Get(slpId,SLPAddress->Des(),IAPName->Des(),serverEnabled,simChangeRemove,usageInHomeNw,editable);
       
   856     if(ret == KErrNotFound || slpId == -1 )
   847     if(ret == KErrNotFound || slpId == -1 )
   857         {
   848         {
   858         CleanupStack::PopAndDestroy(2); //SLPAddress,IAPName
   849         CleanupStack::PopAndDestroy(2); //SLPAddress,IAPName
   859         PrintErrorMessage(_L(""),KErrArgument,9);
   850         PrintErrorMessage(_L(""),KErrArgument,9);
   860         User::Leave(KErrArgument); 
   851         User::Leave(KErrArgument); 
   906          }
   897          }
   907      else
   898      else
   908          {
   899          {
   909          OtherProperties &= ~KEditable;
   900          OtherProperties &= ~KEditable;
   910          }
   901          }
   911 
   902      //product configuration flag is not altered here since it should not be modified while updation
       
   903      //and gets set only during addition of a new server through product configuration
       
   904      
   912      TBuf<KGenericStringLen> tempBuf;
   905      TBuf<KGenericStringLen> tempBuf;
   913      tempBuf.Copy(*SLPAddress);
   906      tempBuf.Copy(*SLPAddress);
   914      tempBuf.Trim();
   907      tempBuf.Trim();
   915     iSQLString.Copy(KUpdateRecord);
   908     iSQLString.Copy(KUpdateRecord);
   916     iSQLString.Append(KCreateTableName);
   909     iSQLString.Append(KCreateTableName);
  1154         }
  1147         }
  1155     else
  1148     else
  1156         {
  1149         {
  1157         OtherProperties &= ~KEditable;
  1150         OtherProperties &= ~KEditable;
  1158         }
  1151         }
  1159 
  1152     //product configuration flag is not altered here since it should not be modified while updation
       
  1153     //and gets modified only during addition of a new server
       
  1154     
  1160     TBuf<KGenericStringLen> tempBuf;
  1155     TBuf<KGenericStringLen> tempBuf;
  1161     tempBuf.Copy(*SLPAddress);
  1156     tempBuf.Copy(*SLPAddress);
  1162     tempBuf.Trim();
  1157     tempBuf.Trim();
  1163     iSQLString.Copy(KUpdateRecord);
  1158     iSQLString.Copy(KUpdateRecord);
  1164     iSQLString.Append(KCreateTableName);
  1159     iSQLString.Append(KCreateTableName);
  1689     
  1684     
  1690     TBool serverEnabled = EFalse;
  1685     TBool serverEnabled = EFalse;
  1691     TBool simChangeRemove = EFalse;
  1686     TBool simChangeRemove = EFalse;
  1692     TBool usageInHomeNw = EFalse;
  1687     TBool usageInHomeNw = EFalse;
  1693     TBool editable = EFalse;
  1688     TBool editable = EFalse;
  1694 
  1689     TBool prodConfig = ETrue;
  1695 
  1690 
  1696     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  1691     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  1697     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  1692     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  1698     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  1693     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  1699     TInt columnIndexOtherProperties = stmt.ColumnIndex(KColOtherProperties);
  1694     TInt columnIndexOtherProperties = stmt.ColumnIndex(KColOtherProperties);
  1700 
  1695 
  1701     while((err=stmt.Next())==KSqlAtRow)
  1696     while((err=stmt.Next())==KSqlAtRow)
  1702         {
  1697         {
  1703         CServerParams *params = CServerParams::NewL();
  1698         CServerParams *params = CServerParams::NewL();
       
  1699         CleanupStack::PushL(params);
  1704         SLPId = stmt.ColumnInt(columnIndexSLPID);
  1700         SLPId = stmt.ColumnInt(columnIndexSLPID);
  1705         stmt.ColumnText(columnIndexSLPAddress,ServerAddress);
  1701         stmt.ColumnText(columnIndexSLPAddress,ServerAddress);
  1706               
  1702               
  1707         stmt.ColumnText(columnIndexIAP,Iap);            
  1703         stmt.ColumnText(columnIndexIAP,Iap);            
  1708         otherprops = stmt.ColumnInt(columnIndexOtherProperties);
  1704         otherprops = stmt.ColumnInt(columnIndexOtherProperties);
  1713         LogQuery(otherpropbuf);
  1709         LogQuery(otherpropbuf);
  1714         serverEnabled = otherprops & KServerEnabled;
  1710         serverEnabled = otherprops & KServerEnabled;
  1715         simChangeRemove = otherprops & KSimChangeRemove; 
  1711         simChangeRemove = otherprops & KSimChangeRemove; 
  1716         usageInHomeNw = otherprops & KUsageInHomeNw; 
  1712         usageInHomeNw = otherprops & KUsageInHomeNw; 
  1717         editable = otherprops & KEditable;
  1713         editable = otherprops & KEditable;
       
  1714         prodConfig = otherprops & KProductConfigured;
  1718         params->Set(ServerAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  1715         params->Set(ServerAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  1719         aParamValues.Append(params);//ownership transferred to RPointerArray
  1716         params->SetServerConfigurationType(prodConfig);
       
  1717         
       
  1718         aParamValues.AppendL(params);//ownership transferred to RPointerArray
       
  1719         CleanupStack::Pop(params);
  1720         }   
  1720         }   
  1721 
  1721 
  1722     stmt.Close();
  1722     stmt.Close();
  1723     LogAllSLP();
  1723     LogAllSLP();
  1724     }
  1724     }
  1757     
  1757     
  1758     TBool serverEnabled = EFalse;
  1758     TBool serverEnabled = EFalse;
  1759     TBool simChangeRemove = EFalse;
  1759     TBool simChangeRemove = EFalse;
  1760     TBool usageInHomeNw = EFalse;
  1760     TBool usageInHomeNw = EFalse;
  1761     TBool editable = EFalse;
  1761     TBool editable = EFalse;
  1762 
  1762     TBool prodConfig = ETrue;
  1763 
  1763 
  1764     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  1764     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  1765     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  1765     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  1766     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  1766     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  1767     TInt columnIndexOtherProperties = stmt.ColumnIndex(KColOtherProperties);
  1767     TInt columnIndexOtherProperties = stmt.ColumnIndex(KColOtherProperties);
  1768 
  1768 
  1769     while((err=stmt.Next())==KSqlAtRow)
  1769     while((err=stmt.Next())==KSqlAtRow)
  1770         {
  1770         {
  1771         CServerParams *params = CServerParams::NewL();
  1771         CServerParams *params = CServerParams::NewL();
       
  1772         CleanupStack::PushL(params);
  1772         SLPId = stmt.ColumnInt(columnIndexSLPID);
  1773         SLPId = stmt.ColumnInt(columnIndexSLPID);
  1773         stmt.ColumnText(columnIndexSLPAddress,ServerAddress);
  1774         stmt.ColumnText(columnIndexSLPAddress,ServerAddress);
  1774               
  1775               
  1775         stmt.ColumnText(columnIndexIAP,Iap);            
  1776         stmt.ColumnText(columnIndexIAP,Iap);            
  1776         otherprops = stmt.ColumnInt(columnIndexOtherProperties);
  1777         otherprops = stmt.ColumnInt(columnIndexOtherProperties);
  1781         LogQuery(otherpropbuf);
  1782         LogQuery(otherpropbuf);
  1782         serverEnabled = otherprops & KServerEnabled;
  1783         serverEnabled = otherprops & KServerEnabled;
  1783         simChangeRemove = otherprops & KSimChangeRemove; 
  1784         simChangeRemove = otherprops & KSimChangeRemove; 
  1784         usageInHomeNw = otherprops & KUsageInHomeNw; 
  1785         usageInHomeNw = otherprops & KUsageInHomeNw; 
  1785         editable = otherprops & KEditable;
  1786         editable = otherprops & KEditable;
       
  1787         prodConfig = otherprops & KProductConfigured;
  1786         params->Set(ServerAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  1788         params->Set(ServerAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  1787         aParamValues.Append(params);//ownership transferred to RPointerArray
  1789         params->SetServerConfigurationType(prodConfig);
       
  1790         aParamValues.AppendL(params);//ownership transferred to RPointerArray
       
  1791         CleanupStack::Pop(params);
  1788         }   
  1792         }   
  1789 
  1793 
  1790     stmt.Close();
  1794     stmt.Close();
  1791     LogAllSLP();
  1795     LogAllSLP();
  1792     User::RequestComplete(iStatus,KErrNone);
  1796     User::RequestComplete(iStatus,KErrNone);
  2070     
  2074     
  2071     TBool serverEnabled = EFalse;
  2075     TBool serverEnabled = EFalse;
  2072     TBool simChangeRemove = EFalse;
  2076     TBool simChangeRemove = EFalse;
  2073     TBool usageInHomeNw = EFalse;
  2077     TBool usageInHomeNw = EFalse;
  2074     TBool editable = EFalse;
  2078     TBool editable = EFalse;
       
  2079     TBool prodConfig = ETrue;
  2075     
  2080     
  2076     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2081     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2077     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  2082     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  2078     
  2083     
  2079     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  2084     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  2091         
  2096         
  2092         serverEnabled = otherprops & KServerEnabled;
  2097         serverEnabled = otherprops & KServerEnabled;
  2093         simChangeRemove = otherprops & KSimChangeRemove;
  2098         simChangeRemove = otherprops & KSimChangeRemove;
  2094         usageInHomeNw = otherprops & KUsageInHomeNw;
  2099         usageInHomeNw = otherprops & KUsageInHomeNw;
  2095         editable = otherprops & KEditable;
  2100         editable = otherprops & KEditable;
       
  2101         prodConfig = otherprops & KProductConfigured;
  2096         //logging
  2102         //logging
  2097         otherpropbuf.Zero();
  2103         otherpropbuf.Zero();
  2098         otherpropbuf.AppendNum(otherprops);
  2104         otherpropbuf.AppendNum(otherprops);
  2099         LogQuery(serverAddress);
  2105         LogQuery(serverAddress);
  2100         LogQuery(Iap)   ;     
  2106         LogQuery(Iap)   ;     
  2102         }   
  2108         }   
  2103 
  2109 
  2104     stmt.Close();
  2110     stmt.Close();
  2105     
  2111     
  2106     aParamValues->Set(serverAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  2112     aParamValues->Set(serverAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
       
  2113     aParamValues->SetServerConfigurationType(prodConfig);
       
  2114     
  2107     return KErrNone;
  2115     return KErrNone;
  2108     }
  2116     }
  2109 // --------------------------------------------------------------------------------------
  2117 // --------------------------------------------------------------------------------------
  2110 // CSettingsDatabaseHandler::GetSlpInfoFromAddress()
  2118 // CSettingsDatabaseHandler::GetSlpInfoFromAddress()
  2111 //
  2119 //
  2144 
  2152 
  2145     TBool serverEnabled = EFalse;
  2153     TBool serverEnabled = EFalse;
  2146     TBool simChangeRemove = EFalse;
  2154     TBool simChangeRemove = EFalse;
  2147     TBool usageInHomeNw = EFalse;
  2155     TBool usageInHomeNw = EFalse;
  2148     TBool editable = EFalse;
  2156     TBool editable = EFalse;
       
  2157     TBool prodConfig = ETrue;
  2149     
  2158     
  2150     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2159     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2151     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  2160     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  2152     
  2161     
  2153     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  2162     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  2165         
  2174         
  2166         serverEnabled = otherprops & KServerEnabled;
  2175         serverEnabled = otherprops & KServerEnabled;
  2167         simChangeRemove = otherprops & KSimChangeRemove;
  2176         simChangeRemove = otherprops & KSimChangeRemove;
  2168         usageInHomeNw = otherprops & KUsageInHomeNw;
  2177         usageInHomeNw = otherprops & KUsageInHomeNw;
  2169         editable = otherprops & KEditable;
  2178         editable = otherprops & KEditable;
       
  2179         prodConfig = otherprops & KProductConfigured;
  2170         //logging
  2180         //logging
  2171         otherpropbuf.Zero();
  2181         otherpropbuf.Zero();
  2172         otherpropbuf.AppendNum(otherprops);
  2182         otherpropbuf.AppendNum(otherprops);
  2173         LogQuery(serverAddress);
  2183         LogQuery(serverAddress);
  2174         LogQuery(Iap);
  2184         LogQuery(Iap);
  2180     
  2190     
  2181     if(SLPId == -1)//we did not find any server by the slp id that was requested for
  2191     if(SLPId == -1)//we did not find any server by the slp id that was requested for
  2182         return KErrNotFound;
  2192         return KErrNotFound;
  2183     
  2193     
  2184     aParamValues->Set(serverAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  2194     aParamValues->Set(serverAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
       
  2195     aParamValues->SetServerConfigurationType(prodConfig);
  2185     return KErrNone;
  2196     return KErrNone;
  2186     }
  2197     }
  2187 // ------------------------------------------------------------------------------------
  2198 // ------------------------------------------------------------------------------------
  2188 // CSettingsDatabaseHandler::GetDefaultServer()
  2199 // CSettingsDatabaseHandler::GetDefaultServer()
  2189 //
  2200 //
  2216     
  2227     
  2217     TBool serverEnabled = EFalse;
  2228     TBool serverEnabled = EFalse;
  2218     TBool simChangeRemove = EFalse;
  2229     TBool simChangeRemove = EFalse;
  2219     TBool usageInHomeNw = EFalse;
  2230     TBool usageInHomeNw = EFalse;
  2220     TBool editable = EFalse;
  2231     TBool editable = EFalse;
  2221 
  2232     TBool prodConfig = ETrue;
       
  2233     
  2222     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2234     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2223     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  2235     TInt columnIndexSLPAddress = stmt.ColumnIndex(KColSLPAddress);
  2224     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  2236     TInt columnIndexIAP = stmt.ColumnIndex(KColIap);
  2225     TInt columnIndexOtherProperties = stmt.ColumnIndex(KColOtherProperties);
  2237     TInt columnIndexOtherProperties = stmt.ColumnIndex(KColOtherProperties);
  2226 
  2238 
  2234        
  2246        
  2235         serverEnabled = otherprops & KServerEnabled;
  2247         serverEnabled = otherprops & KServerEnabled;
  2236         simChangeRemove = otherprops & KSimChangeRemove;
  2248         simChangeRemove = otherprops & KSimChangeRemove;
  2237         usageInHomeNw = otherprops & KUsageInHomeNw;
  2249         usageInHomeNw = otherprops & KUsageInHomeNw;
  2238         editable = otherprops & KEditable;
  2250         editable = otherprops & KEditable;
       
  2251         prodConfig = otherprops & KProductConfigured;
  2239         //logging
  2252         //logging
  2240         otherpropbuf.Zero();
  2253         otherpropbuf.Zero();
  2241         otherpropbuf.AppendNum(otherprops);
  2254         otherpropbuf.AppendNum(otherprops);
  2242         LogQuery(serverAddress);
  2255         LogQuery(serverAddress);
  2243         LogQuery(Iap);
  2256         LogQuery(Iap);
  2250         return KErrNotFound;
  2263         return KErrNotFound;
  2251         }
  2264         }
  2252     stmt.Close();
  2265     stmt.Close();
  2253 
  2266 
  2254     aParamValues->Set(serverAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
  2267     aParamValues->Set(serverAddress,Iap,serverEnabled,simChangeRemove,usageInHomeNw,editable,SLPId);
       
  2268     aParamValues->SetServerConfigurationType(prodConfig);
  2255     return KErrNone;
  2269     return KErrNone;
  2256     }
  2270     }
  2257 // ---------------------------------------------------------------------------
  2271 // ---------------------------------------------------------------------------
  2258 // CSettingsDatabaseHandler::SlpCount()
  2272 // CSettingsDatabaseHandler::SlpCount()
  2259 //
  2273 //
  2544     //Get all slp ids whose priorities wil get affected
  2558     //Get all slp ids whose priorities wil get affected
  2545     while((err=stmt.Next())==KSqlAtRow)
  2559     while((err=stmt.Next())==KSqlAtRow)
  2546         {
  2560         {
  2547         SLPId = stmt.ColumnInt64(columnIndexSLPID);
  2561         SLPId = stmt.ColumnInt64(columnIndexSLPID);
  2548         if(SLPId != aSlpId)
  2562         if(SLPId != aSlpId)
  2549             slpIndexArray.Append(stmt.ColumnInt64(columnIndexSLPID));
  2563             slpIndexArray.AppendL(stmt.ColumnInt64(columnIndexSLPID));
  2550         }
  2564         }
  2551     stmt.Reset(); 
  2565     stmt.Reset(); 
  2552     stmt.Close();
  2566     stmt.Close();
  2553     //update the priority of the requested server first
  2567     //update the priority of the requested server first
  2554     if(!aDirection)
  2568     if(!aDirection)
  2715     //Get all slp ids whose priorities wil get affected
  2729     //Get all slp ids whose priorities wil get affected
  2716     while((err=stmt.Next())==KSqlAtRow)
  2730     while((err=stmt.Next())==KSqlAtRow)
  2717         {
  2731         {
  2718         SLPId = stmt.ColumnInt64(columnIndexSLPID);
  2732         SLPId = stmt.ColumnInt64(columnIndexSLPID);
  2719         if(SLPId != aSlpId)
  2733         if(SLPId != aSlpId)
  2720             slpIndexArray.Append(stmt.ColumnInt64(columnIndexSLPID));
  2734             slpIndexArray.AppendL(stmt.ColumnInt64(columnIndexSLPID));
  2721         }
  2735         }
  2722     stmt.Reset(); 
  2736     stmt.Reset(); 
  2723     stmt.Close();
  2737     stmt.Close();
  2724     //update the priority of the requested server first
  2738     //update the priority of the requested server first
  2725     iSQLString.Zero();
  2739     iSQLString.Zero();
  2795     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2809     TInt columnIndexSLPID = stmt.ColumnIndex(KColSLPId);
  2796     RArray<TInt64> slpIdArray;
  2810     RArray<TInt64> slpIdArray;
  2797     //Get all slp ids currently in the database
  2811     //Get all slp ids currently in the database
  2798     while((err=stmt.Next())==KSqlAtRow)
  2812     while((err=stmt.Next())==KSqlAtRow)
  2799         {
  2813         {
  2800         slpIdArray.Append(stmt.ColumnInt64(columnIndexSLPID));
  2814         slpIdArray.AppendL(stmt.ColumnInt64(columnIndexSLPID));
  2801         }
  2815         }
  2802     stmt.Reset();
  2816     stmt.Reset();
  2803     
  2817     
  2804     iSQLString.Zero();
  2818     iSQLString.Zero();
  2805 
  2819 
  2912     iSQLString.Append(KDataTypeInteger);
  2926     iSQLString.Append(KDataTypeInteger);
  2913     iSQLString.Append(KCommaSeparator); 
  2927     iSQLString.Append(KCommaSeparator); 
  2914 
  2928 
  2915     iSQLString.Append(KColInterval);
  2929     iSQLString.Append(KColInterval);
  2916     iSQLString.Append(KDataTypeInteger);
  2930     iSQLString.Append(KDataTypeInteger);
       
  2931     iSQLString.Append(KCommaSeparator);
       
  2932     
       
  2933     iSQLString.Append(KColEndTime);
       
  2934     iSQLString.Append(KDataTypeInteger);
       
  2935         
  2917     iSQLString.Append(KClosingBracket);
  2936     iSQLString.Append(KClosingBracket);
  2918     
  2937     
  2919     TInt err = iDb.Exec(iSQLString);
  2938     TInt err = iDb.Exec(iSQLString);
  2920     
  2939     
  2921     PrintErrorMessage(iSQLString,err,1);                            
  2940     PrintErrorMessage(iSQLString,err,1);                            
  2943     TBool triggerNotificationStatus;
  2962     TBool triggerNotificationStatus;
  2944     CTriggerParams::TTriggerType triggerType;
  2963     CTriggerParams::TTriggerType triggerType;
  2945     CTriggerParams::TRequestType requestType;
  2964     CTriggerParams::TRequestType requestType;
  2946     TUint64 outstandingTrigger;
  2965     TUint64 outstandingTrigger;
  2947     TUint64 interval;
  2966     TUint64 interval;
  2948     
  2967     TTime endTime;
  2949     TInt ret = aSessionParamValues->Get(sessionId,sessionName->Des(),notificationPresent,triggerNotificationStatus,
  2968     TInt ret = aSessionParamValues->Get(sessionId,sessionName->Des(),notificationPresent,triggerNotificationStatus,
  2950                              triggerType,requestType,outstandingTrigger,interval );
  2969                              triggerType,requestType,outstandingTrigger,interval );
       
  2970                              
       
  2971          aSessionParamValues->GetTriggerEndTime(endTime);
  2951          
  2972          
       
  2973     TInt64 endTimeInt;
       
  2974     endTimeInt = endTime.Int64();
  2952     if(ret == KErrNotFound)
  2975     if(ret == KErrNotFound)
  2953         {
  2976         {
  2954         delete sessionName;
  2977         delete sessionName;
  2955         User::Leave(KErrGeneral);        
  2978         User::Leave(KErrGeneral);        
  2956         }
  2979         }
  2979         
  3002         
  2980     iSQLString.Append(KColOutstandingTrigger);
  3003     iSQLString.Append(KColOutstandingTrigger);
  2981     iSQLString.Append(KCommaSeparator); 
  3004     iSQLString.Append(KCommaSeparator); 
  2982 
  3005 
  2983     iSQLString.Append(KColInterval);
  3006     iSQLString.Append(KColInterval);
       
  3007     iSQLString.Append(KCommaSeparator);
       
  3008     
       
  3009     iSQLString.Append(KColEndTime);
       
  3010     
  2984     iSQLString.Append(KClosingBracket);
  3011     iSQLString.Append(KClosingBracket);
  2985     
  3012     
  2986     iSQLString.Append(KValues);
  3013     iSQLString.Append(KValues);
  2987 
  3014 
  2988     iSQLString.Append(KOpeningBracket);
  3015     iSQLString.Append(KOpeningBracket);
  3009     
  3036     
  3010     iSQLString.AppendNum(outstandingTrigger);
  3037     iSQLString.AppendNum(outstandingTrigger);
  3011     iSQLString.Append(KCommaSeparator);
  3038     iSQLString.Append(KCommaSeparator);
  3012     
  3039     
  3013     iSQLString.AppendNum(interval);
  3040     iSQLString.AppendNum(interval);
  3014           
  3041     iSQLString.Append(KCommaSeparator);
       
  3042     
       
  3043     iSQLString.AppendNum(endTimeInt);
       
  3044     
  3015     iSQLString.Append(KClosingBracket);
  3045     iSQLString.Append(KClosingBracket);
  3016 
  3046 
  3017     delete sessionName;   
  3047     delete sessionName;   
  3018     TInt err = iDb.Exec(_L("BEGIN")); 
  3048     TInt err = iDb.Exec(_L("BEGIN")); 
  3019     err = iDb.Exec(iSQLString);
  3049     err = iDb.Exec(iSQLString);
  3161     CTriggerParams::TTriggerType triggerType;
  3191     CTriggerParams::TTriggerType triggerType;
  3162     CTriggerParams::TRequestType requestType;
  3192     CTriggerParams::TRequestType requestType;
  3163     TUint64 outstandingTrigger;
  3193     TUint64 outstandingTrigger;
  3164     TUint64 interval;
  3194     TUint64 interval;
  3165     TBuf<KGenericStringLen> sessionName;
  3195     TBuf<KGenericStringLen> sessionName;
  3166     
  3196     TTime endTime;
  3167     TInt columnIndexSessionID = stmt.ColumnIndex(KColSessionId);
  3197     TInt64 endTimeInt;
  3168     TInt columnIndexSessionName = stmt.ColumnIndex(KColSessionName);
       
  3169     TInt columnIndexNotificationPresent = stmt.ColumnIndex(KColNotificationPresent);
       
  3170     TInt columnIndexTriggerNotificationStatus = stmt.ColumnIndex(KColTriggerNotificationStatus);
       
  3171     TInt columnIndexTriggerType = stmt.ColumnIndex(KColTriggerType);
       
  3172     TInt columnIndexRequestType = stmt.ColumnIndex(KColRequestType);
       
  3173     TInt columnIndexOutstandingTrigger = stmt.ColumnIndex(KColOutstandingTrigger);
       
  3174     TInt columnIndexInterval = stmt.ColumnIndex(KColInterval);
       
  3175 
       
  3176     // Reset client array
       
  3177     aParamValues.Reset();
       
  3178     while((err=stmt.Next())==KSqlAtRow)
       
  3179         {
       
  3180         CTriggerParams *params = CTriggerParams::NewL();
       
  3181         sessionId = stmt.ColumnInt(columnIndexSessionID);
       
  3182         stmt.ColumnText(columnIndexSessionName,sessionName);
       
  3183         notificationPresent = stmt.ColumnInt(columnIndexNotificationPresent);
       
  3184         triggerNotificationStatus = stmt.ColumnInt(columnIndexTriggerNotificationStatus);
       
  3185         triggerType = (CTriggerParams::TTriggerType) stmt.ColumnInt(columnIndexTriggerType);
       
  3186         requestType = (CTriggerParams::TRequestType) stmt.ColumnInt(columnIndexRequestType);
       
  3187         outstandingTrigger = stmt.ColumnInt(columnIndexOutstandingTrigger);
       
  3188         interval = stmt.ColumnInt(columnIndexInterval);
       
  3189         
       
  3190         params->Set(sessionId,sessionName,notificationPresent,triggerNotificationStatus,triggerType,requestType,outstandingTrigger,interval);
       
  3191         aParamValues.Append(params);//ownership transferred to RPointerArray
       
  3192         }   
       
  3193 
       
  3194     stmt.Close();
       
  3195     if(aParamValues.Count()==0)
       
  3196         {
       
  3197         User::Leave(KErrNotFound);
       
  3198         }
       
  3199     
       
  3200     }
       
  3201 
       
  3202 
       
  3203 // ---------------------------------------------------------------------------
       
  3204 // CSettingsDatabaseHandler::GetSessionL()
       
  3205 //
       
  3206 // Returns the session parameters for a given session id
       
  3207 // ---------------------------------------------------------------------------
       
  3208 void CSettingsDatabaseHandler::GetSessionL(TInt64 aSessionId,
       
  3209                                                 CTriggerParams*& aParamValues)
       
  3210     {
       
  3211     if( !IsSessionExists(aSessionId) ) //no session exists with the given id so return error
       
  3212         {
       
  3213         User::Leave(KErrNotFound);
       
  3214         }
       
  3215     iSQLString.Copy(KSelect);
       
  3216     iSQLString.Append(KStar);
       
  3217     iSQLString.Append(KFrom);
       
  3218     iSQLString.Append(KSessionTableName); // retrieve list of all session in order of priority
       
  3219     iSQLString.Append(KWhere);
       
  3220     iSQLString.Append(KColSessionId);
       
  3221     iSQLString.Append(KEquals);
       
  3222     iSQLString.AppendNum(aSessionId);
       
  3223         
       
  3224     RSqlStatement stmt;
       
  3225     TInt err = stmt.Prepare(iDb,iSQLString);
       
  3226     if(err != KErrNone)
       
  3227         {
       
  3228         stmt.Close();
       
  3229         User::Leave(KErrGeneral);
       
  3230         }
       
  3231     
       
  3232     TInt64 sessionId;
       
  3233     TBool notificationPresent;
       
  3234     TBool triggerNotificationStatus;
       
  3235     CTriggerParams::TTriggerType triggerType;
       
  3236     CTriggerParams::TRequestType requestType;
       
  3237     TUint64 outstandingTrigger;
       
  3238     TUint64 interval;
       
  3239     TBuf<KGenericStringLen> sessionName;
       
  3240         
  3198         
  3241     TInt columnIndexSessionID = stmt.ColumnIndex(KColSessionId);
  3199     TInt columnIndexSessionID = stmt.ColumnIndex(KColSessionId);
  3242     TInt columnIndexSessionName = stmt.ColumnIndex(KColSessionName);
  3200     TInt columnIndexSessionName = stmt.ColumnIndex(KColSessionName);
  3243     TInt columnIndexNotificationPresent = stmt.ColumnIndex(KColNotificationPresent);
  3201     TInt columnIndexNotificationPresent = stmt.ColumnIndex(KColNotificationPresent);
  3244     TInt columnIndexTriggerNotificationStatus = stmt.ColumnIndex(KColTriggerNotificationStatus);
  3202     TInt columnIndexTriggerNotificationStatus = stmt.ColumnIndex(KColTriggerNotificationStatus);
  3245     TInt columnIndexTriggerType = stmt.ColumnIndex(KColTriggerType);
  3203     TInt columnIndexTriggerType = stmt.ColumnIndex(KColTriggerType);
  3246     TInt columnIndexRequestType = stmt.ColumnIndex(KColRequestType);
  3204     TInt columnIndexRequestType = stmt.ColumnIndex(KColRequestType);
  3247     TInt columnIndexOutstandingTrigger = stmt.ColumnIndex(KColOutstandingTrigger);
  3205     TInt columnIndexOutstandingTrigger = stmt.ColumnIndex(KColOutstandingTrigger);
  3248     TInt columnIndexInterval = stmt.ColumnIndex(KColInterval);
  3206     TInt columnIndexInterval = stmt.ColumnIndex(KColInterval);
       
  3207     TInt columnIndexEndTime = stmt.ColumnIndex(KColEndTime);
       
  3208 
       
  3209     // Reset client array
       
  3210     aParamValues.Reset();
  3249     while((err=stmt.Next())==KSqlAtRow)
  3211     while((err=stmt.Next())==KSqlAtRow)
  3250         {
  3212         {
       
  3213         CTriggerParams *params = CTriggerParams::NewL();
       
  3214         CleanupStack::PushL(params);
  3251         sessionId = stmt.ColumnInt(columnIndexSessionID);
  3215         sessionId = stmt.ColumnInt(columnIndexSessionID);
  3252         stmt.ColumnText(columnIndexSessionName,sessionName);
  3216         stmt.ColumnText(columnIndexSessionName,sessionName);
  3253         notificationPresent = stmt.ColumnInt(columnIndexNotificationPresent);
  3217         notificationPresent = stmt.ColumnInt(columnIndexNotificationPresent);
  3254         triggerNotificationStatus = stmt.ColumnInt(columnIndexTriggerNotificationStatus);
  3218         triggerNotificationStatus = stmt.ColumnInt(columnIndexTriggerNotificationStatus);
  3255         triggerType = (CTriggerParams::TTriggerType) stmt.ColumnInt(columnIndexTriggerType);
  3219         triggerType = (CTriggerParams::TTriggerType) stmt.ColumnInt(columnIndexTriggerType);
  3256         requestType = (CTriggerParams::TRequestType) stmt.ColumnInt(columnIndexRequestType);
  3220         requestType = (CTriggerParams::TRequestType) stmt.ColumnInt(columnIndexRequestType);
  3257         outstandingTrigger = stmt.ColumnInt(columnIndexOutstandingTrigger);
  3221         outstandingTrigger = stmt.ColumnInt(columnIndexOutstandingTrigger);
  3258         interval = stmt.ColumnInt(columnIndexInterval);
  3222         interval = stmt.ColumnInt(columnIndexInterval);
  3259                 
  3223         endTimeInt = stmt.ColumnInt64(columnIndexEndTime);
       
  3224         endTime = endTimeInt;
       
  3225         params->Set(sessionId,sessionName,notificationPresent,triggerNotificationStatus,triggerType,requestType,outstandingTrigger,interval);
       
  3226 				params->SetTriggerEndTime(endTime);        
       
  3227         aParamValues.AppendL(params);//ownership transferred to RPointerArray
       
  3228         CleanupStack::Pop(params);
       
  3229         }   
       
  3230 
       
  3231     stmt.Close();
       
  3232     if(aParamValues.Count()==0)
       
  3233         {
       
  3234         User::Leave(KErrNotFound);
       
  3235         }
       
  3236     
       
  3237     }
       
  3238 
       
  3239 
       
  3240 // ---------------------------------------------------------------------------
       
  3241 // CSettingsDatabaseHandler::GetSessionL()
       
  3242 //
       
  3243 // Returns the session parameters for a given session id
       
  3244 // ---------------------------------------------------------------------------
       
  3245 void CSettingsDatabaseHandler::GetSessionL(TInt64 aSessionId,
       
  3246                                                 CTriggerParams*& aParamValues)
       
  3247     {
       
  3248     if( !IsSessionExists(aSessionId) ) //no session exists with the given id so return error
       
  3249         {
       
  3250         User::Leave(KErrNotFound);
       
  3251         }
       
  3252     iSQLString.Copy(KSelect);
       
  3253     iSQLString.Append(KStar);
       
  3254     iSQLString.Append(KFrom);
       
  3255     iSQLString.Append(KSessionTableName); // retrieve list of all session in order of priority
       
  3256     iSQLString.Append(KWhere);
       
  3257     iSQLString.Append(KColSessionId);
       
  3258     iSQLString.Append(KEquals);
       
  3259     iSQLString.AppendNum(aSessionId);
       
  3260         
       
  3261     RSqlStatement stmt;
       
  3262     TInt err = stmt.Prepare(iDb,iSQLString);
       
  3263     if(err != KErrNone)
       
  3264         {
       
  3265         stmt.Close();
       
  3266         User::Leave(KErrGeneral);
       
  3267         }
       
  3268     
       
  3269     TInt64 sessionId;
       
  3270     TBool notificationPresent;
       
  3271     TBool triggerNotificationStatus;
       
  3272     CTriggerParams::TTriggerType triggerType;
       
  3273     CTriggerParams::TRequestType requestType;
       
  3274     TUint64 outstandingTrigger;
       
  3275     TUint64 interval;
       
  3276     TBuf<KGenericStringLen> sessionName;
       
  3277     TTime endTime;
       
  3278     TInt64 endTimeInt;
       
  3279     
       
  3280         
       
  3281     TInt columnIndexSessionID = stmt.ColumnIndex(KColSessionId);
       
  3282     TInt columnIndexSessionName = stmt.ColumnIndex(KColSessionName);
       
  3283     TInt columnIndexNotificationPresent = stmt.ColumnIndex(KColNotificationPresent);
       
  3284     TInt columnIndexTriggerNotificationStatus = stmt.ColumnIndex(KColTriggerNotificationStatus);
       
  3285     TInt columnIndexTriggerType = stmt.ColumnIndex(KColTriggerType);
       
  3286     TInt columnIndexRequestType = stmt.ColumnIndex(KColRequestType);
       
  3287     TInt columnIndexOutstandingTrigger = stmt.ColumnIndex(KColOutstandingTrigger);
       
  3288     TInt columnIndexInterval = stmt.ColumnIndex(KColInterval);
       
  3289     TInt columnIndexEndTime = stmt.ColumnIndex(KColEndTime);
       
  3290     
       
  3291     while((err=stmt.Next())==KSqlAtRow)
       
  3292         {
       
  3293         sessionId = stmt.ColumnInt(columnIndexSessionID);
       
  3294         stmt.ColumnText(columnIndexSessionName,sessionName);
       
  3295         notificationPresent = stmt.ColumnInt(columnIndexNotificationPresent);
       
  3296         triggerNotificationStatus = stmt.ColumnInt(columnIndexTriggerNotificationStatus);
       
  3297         triggerType = (CTriggerParams::TTriggerType) stmt.ColumnInt(columnIndexTriggerType);
       
  3298         requestType = (CTriggerParams::TRequestType) stmt.ColumnInt(columnIndexRequestType);
       
  3299         outstandingTrigger = stmt.ColumnInt(columnIndexOutstandingTrigger);
       
  3300         interval = stmt.ColumnInt(columnIndexInterval);
       
  3301         endTimeInt = stmt.ColumnInt64(columnIndexEndTime);
       
  3302         endTime = endTimeInt;
  3260         aParamValues->Set(sessionId,sessionName,notificationPresent,triggerNotificationStatus,triggerType,requestType,outstandingTrigger,interval);
  3303         aParamValues->Set(sessionId,sessionName,notificationPresent,triggerNotificationStatus,triggerType,requestType,outstandingTrigger,interval);
       
  3304         aParamValues->SetTriggerEndTime(endTime);
  3261         }   
  3305         }   
  3262 
  3306 
  3263     stmt.Close();
  3307     stmt.Close();
  3264     }
  3308     }
  3265 
  3309