Hi Samuel
On 07/06/2011 05:40 PM, Samuel Ortiz wrote:
> Hi Daniel,
>
> On Fri, Jul 01, 2011 at 06:15:42PM +0200, Daniel Wagner wrote:
>> From: Daniel Wagner <[email protected]>
>>
>> I don't think this is a good solution because the magic to choose the
>> right network for the service shouldn't be part of device. Maybe
>> passing the networks to service to select the right one would be
>> better?
> It would make more sense for the network selection logic to belong to
> service.c, even though I don't see how we would do anything else but a
> strength based selection algorithm.
Yes, I completely agree and I'll move the part to service.c
> Some more comments below:
>
>
>> @@ -1119,6 +1121,32 @@ int connman_device_remove_network(struct
>> connman_device *device,
>>
>> g_hash_table_remove(device->networks, identifier);
>>
>> + network = NULL;
>> +
>> + g_hash_table_iter_init(&iter, device->networks);
>> +
>> + while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) {
>> + struct connman_network *iter_network = value;
>> + uint8_t strength, iter_strength;
>> +
>> + if (network == NULL) {
>> + network = iter_network;
>> + continue;
>> + }
>> +
>> + strength = connman_network_get_strength(network);
>> + iter_strength = connman_network_get_strength(iter_network);
>> +
>> + if (iter_strength > strength)
>> + network = iter_network;
>> + }
>> +
>> + if (network == NULL)
>> + return 0;
>> +
>> + __connman_device_set_network(device, network);
>> + __connman_service_update_from_network(network);
>
> So here we probably should provide a service.c routine (e.g.
> __connman_service_reset_from_networks(GHashTable *networks)) that would
> basically select a network from a networks hash table and then call
> __connman_service_create_from_network() with it.
okay
> service_update_from_network
> will not set the right service->network pointer for you.
> This routine should also set the service->network pointer to NULL if the hash
> table is empty.
Thanks for the explanation.
cheers,
daniel
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman