cmmanager/cmmgr/cmmserver/src/cmmcache.cpp
changeset 23 7ec726f93df1
parent 20 9c97ad6591ae
child 27 489cf6208544
equal deleted inserted replaced
20:9c97ad6591ae 23:7ec726f93df1
  1638             if ( iDestinationArray[index]->GetStatus() == ECmmDestinationStatusToBeDeleted )
  1638             if ( iDestinationArray[index]->GetStatus() == ECmmDestinationStatusToBeDeleted )
  1639                 {
  1639                 {
  1640                 // Delete the destination unless an active connection is using
  1640                 // Delete the destination unless an active connection is using
  1641                 // one of it's connection methods.
  1641                 // one of it's connection methods.
  1642                 TRAP_IGNORE( DeleteDestinationForcedL( aDestinationInstance ) );
  1642                 TRAP_IGNORE( DeleteDestinationForcedL( aDestinationInstance ) );
  1643                         //{
       
  1644                         //if ( !DestinationConnectedL( aDestinationInstance.GetId() ) ) DeleteDestinationL( aDestinationInstance, ETrue );
       
  1645                         //} ); //TODO, make helper function
       
  1646 
       
  1647                 // Destination is now removed from database. Tell instance
  1643                 // Destination is now removed from database. Tell instance
  1648                 // mapping to stop ignoring the related ID.
  1644                 // mapping to stop ignoring the related ID.
  1649                 iInstanceMapping->RemoveDestinationFromDeletedList( aDestinationInstance.GetId() );
  1645                 iInstanceMapping->RemoveDestinationFromDeletedList( aDestinationInstance.GetId() );
  1650                 }
  1646                 }
  1651 
  1647 
  1697             // No more references, no client has an open handle to this, delete it.
  1693             // No more references, no client has an open handle to this, delete it.
  1698             delete iConnMethodArray[index];
  1694             delete iConnMethodArray[index];
  1699             iConnMethodArray.Remove( index );
  1695             iConnMethodArray.Remove( index );
  1700             }
  1696             }
  1701         }
  1697         }
       
  1698 
  1702     OstTraceFunctionExit0( CCMMCACHE_CLOSECONNMETHOD_EXIT );
  1699     OstTraceFunctionExit0( CCMMCACHE_CLOSECONNMETHOD_EXIT );
  1703     }
  1700     }
  1704 
  1701 
  1705 //-----------------------------------------------------------------------------
  1702 //-----------------------------------------------------------------------------
  1706 // Returns a reference to the CommsDat session.
  1703 // Returns a reference to the CommsDat session.
  2144         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2141         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2145         }
  2142         }
  2146 
  2143 
  2147     retVal = cmInstance->GetIntAttributeL( aAttribute );
  2144     retVal = cmInstance->GetIntAttributeL( aAttribute );
  2148 
  2145 
  2149     CloseConnMethod( *cmInstance );
       
  2150     CleanupStack::PopAndDestroy( cmInstance );
  2146     CleanupStack::PopAndDestroy( cmInstance );
  2151 
  2147 
  2152     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOINTL_EXIT );
  2148     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOINTL_EXIT );
  2153     return retVal;
  2149     return retVal;
  2154     }
  2150     }
  2179         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2175         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2180         }
  2176         }
  2181 
  2177 
  2182     retVal = cmInstance->GetBoolAttributeL( aAttribute );
  2178     retVal = cmInstance->GetBoolAttributeL( aAttribute );
  2183 
  2179 
  2184     CloseConnMethod( *cmInstance );
       
  2185     CleanupStack::PopAndDestroy( cmInstance );
  2180     CleanupStack::PopAndDestroy( cmInstance );
  2186 
  2181 
  2187     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOBOOLL_EXIT );
  2182     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOBOOLL_EXIT );
  2188     return retVal;
  2183     return retVal;
  2189     }
  2184     }
  2214         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2209         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2215         }
  2210         }
  2216 
  2211 
  2217     retVal = cmInstance->GetStringAttributeL( aAttribute );
  2212     retVal = cmInstance->GetStringAttributeL( aAttribute );
  2218 
  2213 
  2219     CloseConnMethod( *cmInstance );
       
  2220     CleanupStack::PopAndDestroy( cmInstance );
  2214     CleanupStack::PopAndDestroy( cmInstance );
  2221 
  2215 
  2222     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRINGL_EXIT );
  2216     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRINGL_EXIT );
  2223     return retVal;
  2217     return retVal;
  2224     }
  2218     }
  2249         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2243         OpenConnectionMethodInstanceL( *cmInstance, aCmId );
  2250         }
  2244         }
  2251 
  2245 
  2252     retVal = cmInstance->GetString8AttributeL( aAttribute );
  2246     retVal = cmInstance->GetString8AttributeL( aAttribute );
  2253 
  2247 
  2254     CloseConnMethod( *cmInstance );
       
  2255     CleanupStack::PopAndDestroy( cmInstance );
  2248     CleanupStack::PopAndDestroy( cmInstance );
  2256 
  2249 
  2257     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRING8L_EXIT );
  2250     OstTraceFunctionExit0( CCMMCACHE_GETCONNECTIONMETHODINFOSTRING8L_EXIT );
  2258     return retVal;
  2251     return retVal;
  2259     }
  2252     }
  2567             }
  2560             }
  2568         ss.Close();
  2561         ss.Close();
  2569         }
  2562         }
  2570 
  2563 
  2571     OstTraceFunctionExit0( CCMMCACHE_CHECKIFCMCONNECTED_EXIT );
  2564     OstTraceFunctionExit0( CCMMCACHE_CHECKIFCMCONNECTED_EXIT );
  2572 
       
  2573     return result;
  2565     return result;
  2574     }
  2566     }
  2575 
  2567 
  2576 // ---------------------------------------------------------------------------
  2568 // ---------------------------------------------------------------------------
  2577 // Enumerates connections and checks if any of the connection methods in the
  2569 // Enumerates connections and checks if any of the connection methods in the
  2578 // given destination is connected.
  2570 // given destination is connected.
       
  2571 // If pointer to destination instance is given, then information about
       
  2572 // relevant connection methods is retrieved from that. Otherwise the
       
  2573 // information is retrieved from instance mapping using the given ID.
  2579 // ---------------------------------------------------------------------------
  2574 // ---------------------------------------------------------------------------
  2580 //
  2575 //
  2581 TBool CCmmCache::DestinationConnectedL(
  2576 TBool CCmmCache::DestinationConnectedL(
  2582         const TUint32 aDestinationId,
  2577         const TUint32 aDestinationId,
  2583         CCmmDestinationInstance* aDestinationInstance ) const
  2578         CCmmDestinationInstance* aDestinationInstance ) const
  2657     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONISEMBEDDED_ENTRY );
  2652     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONISEMBEDDED_ENTRY );
  2658 
  2653 
  2659     TBool isEmbedded = iInstanceMapping->DestinationIsEmbedded( aDestinationId );
  2654     TBool isEmbedded = iInstanceMapping->DestinationIsEmbedded( aDestinationId );
  2660 
  2655 
  2661     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONISEMBEDDED_EXIT );
  2656     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONISEMBEDDED_EXIT );
  2662 
       
  2663     return isEmbedded;
  2657     return isEmbedded;
  2664     }
  2658     }
  2665 
  2659 
  2666 // ---------------------------------------------------------------------------
  2660 // ---------------------------------------------------------------------------
  2667 // Check from database if the given destination has an embedded destination.
  2661 // Check from database if the given destination has an embedded destination.
  2672     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONHASEMBEDDED_ENTRY );
  2666     OstTraceFunctionEntry0( CCMMCACHE_DESTINATIONHASEMBEDDED_ENTRY );
  2673 
  2667 
  2674     TBool hasEmbedded = iInstanceMapping->DestinationHasEmbedded( aDestinationId );
  2668     TBool hasEmbedded = iInstanceMapping->DestinationHasEmbedded( aDestinationId );
  2675 
  2669 
  2676     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONHASEMBEDDED_EXIT );
  2670     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONHASEMBEDDED_EXIT );
  2677 
       
  2678     return hasEmbedded;
  2671     return hasEmbedded;
  2679     }
  2672     }
  2680 
  2673 
  2681 // ---------------------------------------------------------------------------
  2674 // ---------------------------------------------------------------------------
  2682 // Check from database if the given destination is pointed to by any virtual
  2675 // Check from database if the given destination is pointed to by any virtual
  2689 
  2682 
  2690     TBool pointedByVirtual =
  2683     TBool pointedByVirtual =
  2691             iInstanceMapping->DestinationPointedToByVirtualIap( aDestinationId );
  2684             iInstanceMapping->DestinationPointedToByVirtualIap( aDestinationId );
  2692 
  2685 
  2693     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONPOINTEDTOBYVIRTUALIAP_EXIT );
  2686     OstTraceFunctionExit0( CCMMCACHE_DESTINATIONPOINTEDTOBYVIRTUALIAP_EXIT );
  2694 
       
  2695     return pointedByVirtual;
  2687     return pointedByVirtual;
  2696     }
  2688     }
  2697 
  2689 
  2698 // ---------------------------------------------------------------------------
  2690 // ---------------------------------------------------------------------------
  2699 // Check from database if the given connection method is pointed to by any
  2691 // Check from database if the given connection method is pointed to by any
  2721 
  2713 
  2722     TBool inAndlocked = iInstanceMapping->
  2714     TBool inAndlocked = iInstanceMapping->
  2723             ConnMethodInDestinationButLocked( aConnMethodId, aDestinationId );
  2715             ConnMethodInDestinationButLocked( aConnMethodId, aDestinationId );
  2724 
  2716 
  2725     OstTraceFunctionExit0( CCMMCACHE_CONNMETHODINDESTINATIONBUTLOCKED_EXIT );
  2717     OstTraceFunctionExit0( CCMMCACHE_CONNMETHODINDESTINATIONBUTLOCKED_EXIT );
  2726 
       
  2727     return inAndlocked;
  2718     return inAndlocked;
  2728     }
  2719     }
  2729 
  2720 
  2730 // ---------------------------------------------------------------------------
  2721 // ---------------------------------------------------------------------------
  2731 // Remove all references to the given connection method from the datamobility
  2722 // Remove all references to the given connection method from the datamobility
  2817             {
  2808             {
  2818             iDestinationArray[i]->SetId( aIdStruct.iRealId );
  2809             iDestinationArray[i]->SetId( aIdStruct.iRealId );
  2819             break;
  2810             break;
  2820             }
  2811             }
  2821         }
  2812         }
       
  2813 
  2822     OstTraceFunctionExit0( CCMMCACHE_REFRESHDESTINATIONID_EXIT );
  2814     OstTraceFunctionExit0( CCMMCACHE_REFRESHDESTINATIONID_EXIT );
  2823     }
  2815     }
  2824 
  2816 
  2825 // ---------------------------------------------------------------------------
  2817 // ---------------------------------------------------------------------------
  2826 // Update the ID of a new connection method from temporary ID to real ID after
  2818 // Update the ID of a new connection method from temporary ID to real ID after
  2838             {
  2830             {
  2839             iConnMethodArray[i]->SetId( aIdStruct.iRealId );
  2831             iConnMethodArray[i]->SetId( aIdStruct.iRealId );
  2840             break; // Can only be 1 match.
  2832             break; // Can only be 1 match.
  2841             }
  2833             }
  2842         }
  2834         }
       
  2835 
  2843     OstTraceFunctionExit0( CCMMCACHE_REFRESHCONNMETHODID_EXIT );
  2836     OstTraceFunctionExit0( CCMMCACHE_REFRESHCONNMETHODID_EXIT );
  2844     }
  2837     }
  2845 
  2838 
  2846 // ---------------------------------------------------------------------------
  2839 // ---------------------------------------------------------------------------
  2847 // During destination update, after updating connection methods inside the
  2840 // During destination update, after updating connection methods inside the
  2868         }
  2861         }
  2869     if ( !aRealId )
  2862     if ( !aRealId )
  2870         {
  2863         {
  2871         ASSERT( 0 );
  2864         ASSERT( 0 );
  2872         }
  2865         }
       
  2866 
  2873     OstTraceFunctionExit0( CCMMCACHE_TRANSLATETEMPORARYID_EXIT );
  2867     OstTraceFunctionExit0( CCMMCACHE_TRANSLATETEMPORARYID_EXIT );
  2874     }
  2868     }
  2875 
  2869 
  2876 // ---------------------------------------------------------------------------
  2870 // ---------------------------------------------------------------------------
  2877 // Check if the given connection method can have all references removed and
  2871 // Check if the given connection method can have all references removed and
  3035     {
  3029     {
  3036     return iCmManagerImpl->TableId( aRecord );
  3030     return iCmManagerImpl->TableId( aRecord );
  3037     }
  3031     }
  3038 
  3032 
  3039 // ---------------------------------------------------------------------------
  3033 // ---------------------------------------------------------------------------
  3040 // TODO
  3034 // Initiate the deletion of given destination if none of the connection
       
  3035 // methods inside it are connected.
  3041 // ---------------------------------------------------------------------------
  3036 // ---------------------------------------------------------------------------
  3042 //
  3037 //
  3043 void CCmmCache::DeleteDestinationForcedL( CCmmDestinationInstance& aDestinationInstance ) //TODO, OST
  3038 void CCmmCache::DeleteDestinationForcedL( CCmmDestinationInstance& aDestinationInstance ) //TODO, OST
  3044     {
  3039     {
  3045     //TODO
  3040     //TODO
  3046     if ( !DestinationConnectedL( 0, &aDestinationInstance ) )
  3041     if ( !DestinationConnectedL( 0, &aDestinationInstance ) )
  3047     //if ( !DestinationConnectedL( aDestinationInstance.GetId() ) ) //TODO
       
  3048         {
  3042         {
  3049         DeleteDestinationL( aDestinationInstance, ETrue );
  3043         DeleteDestinationL( aDestinationInstance, ETrue );
  3050         }
  3044         }
  3051     }
  3045     }
  3052 
  3046