19 /* |
19 /* |
20 * Here is the plugin managing logic for the AT commands and hopefully also for |
20 * Here is the plugin managing logic for the AT commands and hopefully also for |
21 * future needs: |
21 * future needs: |
22 * |
22 * |
23 * Three types of support: |
23 * Three types of support: |
24 * 1) Master (M): Does not send to S if support found. |
24 * 1) Master (M): Sends to all O if support found. Panics if > 1 M. |
25 * 2) Primary (P): Sends to all S if support found. |
25 * 2) Partial (P): Sends to all O if support found. Replies "ERROR" if two P supports. |
26 * 3) Secondary (S): Process the command and give or not give reply, based on |
26 * 3) Observer (O): Process the command and give or not give reply, based on |
27 * the following logic: |
27 * the following logic: |
28 * |
28 * |
29 * => [If] M found, handle command and send reply, stop, [else] |
29 * => [If] M found, handle command and send reply + send to N O {no reply}, stop, [else] |
30 * [If] P found, handle command and send reply + send to N S {no reply}, stop, [else] |
30 * [If] P found, handle command and send reply + send to N O {no reply}, stop, [else] |
31 * [If] > 1 S found, send to N S {no reply}, stop, [else] |
31 * [If] > 1 O found, send to N O {no reply}, stop, [else] |
32 * [If] only 1 S found, handle command and send reply, stop, [else] |
32 * [If] only 1 O found, handle command and send reply, stop, [else] |
33 * Write "ERROR" to client, complete message with KErrNone |
33 * Write "ERROR" to client, complete message with KErrNone |
34 * |
34 * |
35 * When incoming reply: |
35 * When incoming reply: |
36 * => If reply from M, write to client, stop, [else] |
36 * => If reply from M, write to client, stop, [else] |
37 * If reply from P, write to client, stop, [else] |
37 * If reply from P, write to client, stop, [else] |
38 * If reply from S and M, P nor other S exist, write to client, stop, [else] |
38 * If reply from O and M, P nor other O exist, write to client, stop, [else] |
39 * Complete message with KErrNone and empty string |
39 * Complete message with KErrNone and empty string |
40 * |
40 * |
41 * Note: Empty string and "ERROR" string are managed already in HandleCommand() |
41 * Note: Empty string and "ERROR" string are managed already in HandleCommand() |
42 */ |
42 */ |
43 |
43 |
1550 CArrayFixFlat<TATExtOneCmdSupport>* aEntries, |
1553 CArrayFixFlat<TATExtOneCmdSupport>* aEntries, |
1551 TATExtSearchHelper& aSearchHelper, |
1554 TATExtSearchHelper& aSearchHelper, |
1552 TATExtOneCmdSupport& aOneCmdSupport ) |
1555 TATExtOneCmdSupport& aOneCmdSupport ) |
1553 { |
1556 { |
1554 TRACE_FUNC_ENTRY |
1557 TRACE_FUNC_ENTRY |
|
1558 if ( aEntries->Count() > 0 ) |
|
1559 { |
|
1560 TATExtOneCmdSupport& oneCmdSupport = (*aEntries)[0]; |
|
1561 if ( oneCmdSupport.iSupportType == ESupportTypeMaster ) |
|
1562 { |
|
1563 _LIT( KFaultyMaster, "FaultyMaster" ); |
|
1564 User::Panic( KFaultyMaster, EPanicCategoryFaultyMaster ); |
|
1565 } |
|
1566 } |
1555 aEntries->InsertL( 0, aOneCmdSupport ); |
1567 aEntries->InsertL( 0, aOneCmdSupport ); |
1556 if ( aSearchHelper.iPrimaryIndex >= 0 ) |
1568 if ( aSearchHelper.iPartialIndex >= 0 ) |
1557 { |
1569 { |
1558 aSearchHelper.iPrimaryIndex++; |
1570 aSearchHelper.iPartialIndex++; |
1559 } |
1571 } |
1560 if ( aSearchHelper.iSecondaryIndex >= 0 ) |
1572 if ( aSearchHelper.iObserverIndex >= 0 ) |
1561 { |
1573 { |
1562 aSearchHelper.iSecondaryIndex++; |
1574 aSearchHelper.iObserverIndex++; |
1563 } |
1575 } |
1564 TRACE_FUNC_EXIT |
1576 TRACE_FUNC_EXIT |
1565 return 0; |
1577 return 0; |
1566 } |
1578 } |
1567 |
1579 |
1568 // --------------------------------------------------------------------------- |
1580 // --------------------------------------------------------------------------- |
1569 // Adds new primary plugin entry link from plugin support entry to plugin |
1581 // Adds new partial plugin entry link from plugin support entry to plugin |
1570 // entry |
1582 // entry |
1571 // --------------------------------------------------------------------------- |
1583 // --------------------------------------------------------------------------- |
1572 // |
1584 // |
1573 TInt CATExtMetadata::AddNewPrimaryMetadataEntryLinkL( |
1585 TInt CATExtMetadata::AddNewPartialMetadataEntryLinkL( |
1574 CArrayFixFlat<TATExtOneCmdSupport>* aEntries, |
1586 CArrayFixFlat<TATExtOneCmdSupport>* aEntries, |
1575 TATExtSearchHelper& aSearchHelper, |
1587 TATExtSearchHelper& aSearchHelper, |
1576 TATExtOneCmdSupport& aOneCmdSupport ) |
1588 TATExtOneCmdSupport& aOneCmdSupport ) |
1577 { |
1589 { |
1578 TRACE_FUNC_ENTRY |
1590 TRACE_FUNC_ENTRY |
1579 TInt i = aSearchHelper.iPrimaryIndex; |
1591 TInt i = aSearchHelper.iPartialIndex; |
1580 if ( i < 0 ) |
1592 if ( i < 0 ) |
1581 { |
1593 { |
1582 TInt count = aEntries->Count(); |
1594 TInt count = aEntries->Count(); |
1583 for ( i=0; i<count; i++ ) |
1595 for ( i=0; i<count; i++ ) |
1584 { |
1596 { |
1585 TATExtOneCmdSupport& oneCmdSupport = (*aEntries)[i]; |
1597 TATExtOneCmdSupport& oneCmdSupport = (*aEntries)[i]; |
1586 if ( oneCmdSupport.iSupportType==ESupportTypePrimary || |
1598 if ( oneCmdSupport.iSupportType==ESupportTypePartial || |
1587 oneCmdSupport.iSupportType==ESupportTypeSecondary ) |
1599 oneCmdSupport.iSupportType==ESupportTypeObserver ) |
1588 { |
1600 { |
1589 break; |
1601 break; |
1590 } |
1602 } |
1591 } |
1603 } |
1592 aSearchHelper.iPrimaryIndex = i; |
1604 aSearchHelper.iPartialIndex = i; |
1593 } |
1605 } |
1594 aEntries->InsertL( i, aOneCmdSupport ); |
1606 aEntries->InsertL( i, aOneCmdSupport ); |
1595 if ( aSearchHelper.iSecondaryIndex >= 0 ) |
1607 if ( aSearchHelper.iObserverIndex >= 0 ) |
1596 { |
1608 { |
1597 aSearchHelper.iSecondaryIndex++; |
1609 aSearchHelper.iObserverIndex++; |
1598 } |
1610 } |
1599 TRACE_FUNC_EXIT |
1611 TRACE_FUNC_EXIT |
1600 return i; |
1612 return i; |
1601 } |
1613 } |
1602 |
1614 |
1603 // --------------------------------------------------------------------------- |
1615 // --------------------------------------------------------------------------- |
1604 // Adds new secondary plugin entry link from plugin support entry to plugin |
1616 // Adds new observer plugin entry link from plugin support entry to plugin |
1605 // entry. Search starts from the front as there could be multiple S plugins |
1617 // entry. Search starts from the front as there could be multiple O plugins |
1606 // but only one or two M/P plugins. |
1618 // but only one or two M/P plugins. |
1607 // --------------------------------------------------------------------------- |
1619 // --------------------------------------------------------------------------- |
1608 // |
1620 // |
1609 TInt CATExtMetadata::AddNewSecondaryMetadataEntryLinkL( |
1621 TInt CATExtMetadata::AddNewObserverMetadataEntryLinkL( |
1610 CArrayFixFlat<TATExtOneCmdSupport>* aEntries, |
1622 CArrayFixFlat<TATExtOneCmdSupport>* aEntries, |
1611 TATExtSearchHelper& aSearchHelper, |
1623 TATExtSearchHelper& aSearchHelper, |
1612 TATExtOneCmdSupport& aOneCmdSupport ) |
1624 TATExtOneCmdSupport& aOneCmdSupport ) |
1613 { |
1625 { |
1614 TRACE_FUNC_ENTRY |
1626 TRACE_FUNC_ENTRY |
1615 TInt i = aSearchHelper.iSecondaryIndex; |
1627 TInt i = aSearchHelper.iObserverIndex; |
1616 if ( i < 0 ) |
1628 if ( i < 0 ) |
1617 { |
1629 { |
1618 TInt count = aEntries->Count(); |
1630 TInt count = aEntries->Count(); |
1619 for ( i=0; i<count; i++ ) |
1631 for ( i=0; i<count; i++ ) |
1620 { |
1632 { |
1621 TATExtOneCmdSupport& oneCmdSupport = (*aEntries)[i]; |
1633 TATExtOneCmdSupport& oneCmdSupport = (*aEntries)[i]; |
1622 if ( oneCmdSupport.iSupportType == ESupportTypeSecondary ) |
1634 if ( oneCmdSupport.iSupportType == ESupportTypeObserver ) |
1623 { |
1635 { |
1624 break; |
1636 break; |
1625 } |
1637 } |
1626 } |
1638 } |
1627 aSearchHelper.iSecondaryIndex = i; |
1639 aSearchHelper.iObserverIndex = i; |
1628 } |
1640 } |
1629 aEntries->InsertL( i, aOneCmdSupport ); |
1641 aEntries->InsertL( i, aOneCmdSupport ); |
1630 TRACE_FUNC_EXIT |
1642 TRACE_FUNC_EXIT |
1631 return i; |
1643 return i; |
1632 } |
1644 } |
2020 iCmdData.iHandler = NULL; |
2038 iCmdData.iHandler = NULL; |
2021 TRACE_FUNC_EXIT |
2039 TRACE_FUNC_EXIT |
2022 } |
2040 } |
2023 |
2041 |
2024 // --------------------------------------------------------------------------- |
2042 // --------------------------------------------------------------------------- |
2025 // Handles support when a master plugin is detected in the plugin data via |
2043 // Handles support when a master or partial plugin is detected in the plugin |
2026 // support data's link (support for a full AT command). If a master plugin is |
2044 // data via support data's link. If a partial or master plugin is detected |
2027 // detected then reply is detected from that plugin. No further sending to |
2045 // then reply is expected from that plugin. Also if one or more observer |
2028 // primary or secondary plugins is repformed. |
2046 // plugins are detected then no reply is expected from them. |
2029 // --------------------------------------------------------------------------- |
2047 // --------------------------------------------------------------------------- |
2030 // |
2048 // |
2031 TBool CATExtMetadata::HandleMasterPluginSupportL( |
2049 TBool CATExtMetadata::HandleMasterAndPartialPluginSupportL( |
2032 TATExtEntrySupport& aEntrySupport, |
|
2033 TBool& aReplyExpected ) |
|
2034 { |
|
2035 TRACE_FUNC_ENTRY |
|
2036 aReplyExpected = EFalse; |
|
2037 TBool supported = HandleCommandSupportL( aEntrySupport ); |
|
2038 if ( !supported ) |
|
2039 { |
|
2040 TRACE_FUNC_EXIT |
|
2041 return EFalse; |
|
2042 } |
|
2043 iCmdData.iReplyExpected = ETrue; // Set before HandleCommandL() |
|
2044 HandleCommandL( aEntrySupport, ETrue ); |
|
2045 aReplyExpected = ETrue; |
|
2046 TRACE_FUNC_EXIT |
|
2047 return ETrue; |
|
2048 } |
|
2049 |
|
2050 // --------------------------------------------------------------------------- |
|
2051 // Handles support when a primary plugin is detect in the plugin data via |
|
2052 // support data's link. If a primary plugin is detected then reply is expected |
|
2053 // from that plugin. Also if one or more secondary plugins are detected then |
|
2054 // no reply is expected from them. |
|
2055 // --------------------------------------------------------------------------- |
|
2056 // |
|
2057 TBool CATExtMetadata::HandlePrimaryPluginSupportL( |
|
2058 TATExtEntrySupport& aEntrySupport, |
2050 TATExtEntrySupport& aEntrySupport, |
2059 TInt aStartIndex, |
2051 TInt aStartIndex, |
2060 TBool& aReplyExpected ) |
2052 TBool& aReplyExpected ) |
2061 { |
2053 { |
2062 TRACE_FUNC_ENTRY |
2054 TRACE_FUNC_ENTRY |
2063 aReplyExpected = EFalse; |
2055 aReplyExpected = EFalse; |
2064 TBool supported = HandleCommandSupportL( aEntrySupport ); |
2056 if ( !aEntrySupport.iSupportFound ) |
2065 if ( !supported ) |
2057 { |
2066 { |
2058 TBool supported = HandleCommandSupportL( aEntrySupport ); |
2067 TRACE_FUNC_EXIT |
2059 if ( !supported ) |
2068 return EFalse; |
2060 { |
|
2061 TRACE_FUNC_EXIT |
|
2062 return EFalse; |
|
2063 } |
2069 } |
2064 } |
2070 // If HandleCommand() is implemented synchronously, the command must be |
2065 // If HandleCommand() is implemented synchronously, the command must be |
2071 // saved before executing as CompleteCommandMessage() closes the string |
2066 // saved before executing as CompleteCommandMessage() closes the string |
2072 HBufC8* atCmdFull = HBufC8::NewMaxLC( aEntrySupport.iAtCmdFull.Length() ); |
2067 HBufC8* atCmdFull = HBufC8::NewMaxLC( aEntrySupport.iAtCmdFull.Length() ); |
2073 TPtr8 atCmdFullPtr = atCmdFull->Des(); |
2068 TPtr8 atCmdFullPtr = atCmdFull->Des(); |
2074 atCmdFullPtr.Copy( aEntrySupport.iAtCmdFull ); |
2069 atCmdFullPtr.Copy( aEntrySupport.iAtCmdFull ); |
2075 // Now execute the HandleCommand() |
2070 // Now execute the HandleCommand() |
2076 iCmdData.iReplyExpected = ETrue; // Set before HandleCommandL() |
2071 iCmdData.iReplyExpected = ETrue; // Set before HandleCommandL() |
2077 HandleCommandL( aEntrySupport, ETrue ); |
2072 HandleCommandL( aEntrySupport, ETrue ); |
2078 aEntrySupport.iStartIndex = aStartIndex; |
2073 aEntrySupport.iStartIndex = aStartIndex; |
2079 SendToMultipleSecondaryL( aEntrySupport, atCmdFull ); |
2074 SendToMultipleObserverL( aEntrySupport, atCmdFull ); |
2080 CleanupStack::PopAndDestroy( atCmdFull ); |
2075 CleanupStack::PopAndDestroy( atCmdFull ); |
2081 aReplyExpected = ETrue; |
2076 aReplyExpected = ETrue; |
2082 TRACE_FUNC_EXIT |
2077 TRACE_FUNC_EXIT |
2083 return ETrue; |
2078 return ETrue; |
2084 } |
2079 } |
2085 |
2080 |
2086 // --------------------------------------------------------------------------- |
2081 // --------------------------------------------------------------------------- |
2087 // Handles support when a secondary plugin is detected in the plugin data via |
2082 // Handles support when a observer plugin is detected in the plugin data via |
2088 // support data's link. If only one secondary plugin is detected then reply is |
2083 // support data's link. If only one observer plugin is detected then reply is |
2089 // expected from that plugin. Instead, if more than one secondary plugins are |
2084 // expected from that plugin. Instead, if more than one observer plugins are |
2090 // detected then no reply is expected from them. |
2085 // detected then no reply is expected from them. |
2091 // --------------------------------------------------------------------------- |
2086 // --------------------------------------------------------------------------- |
2092 // |
2087 // |
2093 TBool CATExtMetadata::HandleSecondaryPluginSupportL( |
2088 TBool CATExtMetadata::HandleObserverPluginSupportL( |
2094 TATExtEntrySupport& aEntrySupport, |
2089 TATExtEntrySupport& aEntrySupport, |
2095 TInt aStartIndex, |
2090 TInt aStartIndex, |
2096 TBool& aReplyExpected ) |
2091 TBool& aReplyExpected ) |
2097 { |
2092 { |
2098 TRACE_FUNC_ENTRY |
2093 TRACE_FUNC_ENTRY |
2099 aReplyExpected = EFalse; |
2094 aReplyExpected = EFalse; |
2100 TBool supported = HandleCommandSupportL( aEntrySupport ); |
2095 if ( !aEntrySupport.iSupportFound ) |
2101 if ( !supported ) |
2096 { |
2102 { |
2097 TBool supported = HandleCommandSupportL( aEntrySupport ); |
2103 TRACE_FUNC_EXIT |
2098 if ( !supported ) |
2104 return EFalse; |
2099 { |
|
2100 TRACE_FUNC_EXIT |
|
2101 return EFalse; |
|
2102 } |
2105 } |
2103 } |
2106 TATExtEntrySupport nextSupport = aEntrySupport; |
2104 TATExtEntrySupport nextSupport = aEntrySupport; |
2107 nextSupport.iStartIndex = aStartIndex; |
2105 nextSupport.iStartIndex = aStartIndex; |
2108 TBool entryFound = FindFirstSecondarySupportL( nextSupport ); |
2106 TBool entryFound = FindFirstObserverSupportL( nextSupport ); |
2109 if ( entryFound ) |
2107 if ( entryFound ) |
2110 { |
2108 { |
2111 // Entry found; send all without reply request |
2109 // Entry found; send all without reply request |
2112 // If HandleCommand() is implemented synchronously, the command must be |
2110 // If HandleCommand() is implemented synchronously, the command must be |
2113 // saved before executing as CompleteCommandMessage() closes the string |
2111 // saved before executing as CompleteCommandMessage() closes the string |
2114 HBufC8* atCmdFull = HBufC8::NewMaxLC( aEntrySupport.iAtCmdFull.Length() ); |
2112 HBufC8* atCmdFull = HBufC8::NewMaxLC( aEntrySupport.iAtCmdFull.Length() ); |
2115 TPtr8 atCmdFullPtr = atCmdFull->Des(); |
2113 TPtr8 atCmdFullPtr = atCmdFull->Des(); |
2116 atCmdFullPtr.Copy( aEntrySupport.iAtCmdFull ); |
2114 atCmdFullPtr.Copy( aEntrySupport.iAtCmdFull ); |
2117 // Now execute the HandleCommand() |
2115 // Now execute the HandleCommand() |
2118 HandleCommandL( aEntrySupport, EFalse ); |
2116 HandleCommandL( aEntrySupport, EFalse ); |
2119 SendToMultipleSecondaryL( nextSupport, atCmdFull ); |
2117 SendToMultipleObserverL( nextSupport, atCmdFull ); |
2120 CleanupStack::PopAndDestroy( atCmdFull ); |
2118 CleanupStack::PopAndDestroy( atCmdFull ); |
2121 } |
2119 } |
2122 else |
2120 else |
2123 { |
2121 { |
2124 // No entry found; send one with reply request |
2122 // No entry found; send one with reply request |
2125 iCmdData.iReplyExpected = ETrue; // Set before HandleCommandL() |
2123 iCmdData.iReplyExpected = ETrue; // Set before HandleCommandL() |
2126 HandleCommandL( aEntrySupport, ETrue ); |
2124 HandleCommandL( aEntrySupport, ETrue ); |
2127 aReplyExpected = ETrue; |
2125 aReplyExpected = ETrue; |
|
2126 } |
|
2127 TRACE_FUNC_EXIT |
|
2128 return ETrue; |
|
2129 } |
|
2130 |
|
2131 // --------------------------------------------------------------------------- |
|
2132 // Finds exclusive partial plugin support |
|
2133 // --------------------------------------------------------------------------- |
|
2134 // |
|
2135 TBool CATExtMetadata::FindExclusivePartialSupportL( |
|
2136 TATExtEntrySupport& aEntrySupport ) |
|
2137 { |
|
2138 TRACE_FUNC_ENTRY |
|
2139 TInt i; |
|
2140 TInt supports; |
|
2141 TInt count = aEntrySupport.iSupport->Count(); |
|
2142 for ( i=0,supports=0; i<count; i++ ) |
|
2143 { |
|
2144 TATExtOneCmdSupport& oneCmdSupport = (*aEntrySupport.iSupport)[i]; |
|
2145 if ( oneCmdSupport.iSupportType == ESupportTypePartial ) |
|
2146 { |
|
2147 aEntrySupport.iSupportFound = EFalse; |
|
2148 aEntrySupport.iEntry = &(*iPluginData)[oneCmdSupport.iEntryIndex]; |
|
2149 TBool supported = HandleCommandSupportL( aEntrySupport ); |
|
2150 if ( supported ) |
|
2151 { |
|
2152 aEntrySupport.iSupportFound = ETrue; |
|
2153 supports++; |
|
2154 } |
|
2155 if ( supports != 1 ) |
|
2156 { |
|
2157 TRACE_FUNC_EXIT |
|
2158 return EFalse; |
|
2159 } |
|
2160 } |
2128 } |
2161 } |
2129 TRACE_FUNC_EXIT |
2162 TRACE_FUNC_EXIT |
2130 return ETrue; |
2163 return ETrue; |
2131 } |
2164 } |
2132 |
2165 |
2328 TInt i; |
2361 TInt i; |
2329 TInt count = aEntrySupport.iSupport->Count(); |
2362 TInt count = aEntrySupport.iSupport->Count(); |
2330 for ( i=aEntrySupport.iStartIndex; i<count; i++ ) |
2363 for ( i=aEntrySupport.iStartIndex; i<count; i++ ) |
2331 { |
2364 { |
2332 TATExtOneCmdSupport& oneCmdSupport = (*aEntrySupport.iSupport)[i]; |
2365 TATExtOneCmdSupport& oneCmdSupport = (*aEntrySupport.iSupport)[i]; |
2333 if ( oneCmdSupport.iSupportType != ESupportTypeSecondary ) |
2366 if ( oneCmdSupport.iSupportType != ESupportTypeObserver ) |
2334 { |
2367 { |
2335 continue; |
2368 continue; |
2336 } |
2369 } |
2337 aEntrySupport.iEntry = &(*iPluginData)[i]; |
2370 aEntrySupport.iEntry = &(*iPluginData)[oneCmdSupport.iEntryIndex]; |
2338 TBool supported = HandleCommandSupportL( aEntrySupport, aAtCmdFull ); |
2371 TBool supported = EFalse; |
|
2372 if ( !aEntrySupport.iSupportFound ) |
|
2373 { |
|
2374 supported = HandleCommandSupportL( aEntrySupport, aAtCmdFull ); |
|
2375 } |
2339 if ( supported ) |
2376 if ( supported ) |
2340 { |
2377 { |
2341 HandleCommandL( aEntrySupport, EFalse, aAtCmdFull ); |
2378 HandleCommandL( aEntrySupport, EFalse, aAtCmdFull ); |
2342 } |
2379 aEntrySupport.iSupportFound = ETrue; |
2343 } |
2380 } |
2344 TRACE_FUNC_EXIT |
2381 if ( i < count-1 ) |
2345 } |
2382 { |
2346 |
2383 aEntrySupport.iSupportFound = EFalse; |
2347 // --------------------------------------------------------------------------- |
2384 } |
2348 // Finds the first secondary plugin support from a given starting position |
2385 } |
2349 // --------------------------------------------------------------------------- |
2386 TRACE_FUNC_EXIT |
2350 // |
2387 } |
2351 TBool CATExtMetadata::FindFirstSecondarySupportL( |
2388 |
|
2389 // --------------------------------------------------------------------------- |
|
2390 // Finds the first observer plugin support from a given starting position |
|
2391 // --------------------------------------------------------------------------- |
|
2392 // |
|
2393 TBool CATExtMetadata::FindFirstObserverSupportL( |
2352 TATExtEntrySupport& aEntrySupport ) |
2394 TATExtEntrySupport& aEntrySupport ) |
2353 { |
2395 { |
2354 TRACE_FUNC_ENTRY |
2396 TRACE_FUNC_ENTRY |
2355 if ( !aEntrySupport.iSupport ) |
2397 if ( !aEntrySupport.iSupport ) |
2356 { |
2398 { |