コード例 #1
0
ファイル: Scrub.c プロジェクト: BenBergman/gnucash
void
xaccAccountScrubKvp (Account *account)
{
    const gchar *str;
    gchar *str2;
    KvpFrame *frame;

    if (!account) return;

    str = kvp_frame_get_string(account->inst.kvp_data, "notes");
    if (str)
    {
        str2 = g_strstrip(g_strdup(str));
        if (strlen(str2) == 0)
            kvp_frame_set_slot_nc (account->inst.kvp_data, "notes", NULL);
        g_free(str2);
    }

    str = kvp_frame_get_string(account->inst.kvp_data, "placeholder");
    if (str && strcmp(str, "false") == 0)
        kvp_frame_set_slot_nc (account->inst.kvp_data, "placeholder", NULL);

    frame = kvp_frame_get_frame(account->inst.kvp_data, "hbci");
    if (frame && kvp_frame_is_empty(frame))
    {
        kvp_frame_set_frame_nc(account->inst.kvp_data, "hbci", NULL);
    }
}
コード例 #2
0
ファイル: gnc-slots-sql.c プロジェクト: nishmu/gnucash
static void
set_guid_val( gpointer pObject, /*@ null @*/ gpointer pValue )
{
    slot_info_t* pInfo = (slot_info_t*)pObject;

    g_return_if_fail( pObject != NULL );
    if ( pValue == NULL ) return;

    switch ( pInfo->value_type)
    {
    case KVP_TYPE_GUID:
    {
        KvpValue *value = kvp_value_new_guid( (GncGUID*)pValue );
        set_slot_from_value( pInfo, value );
        break;
    }
    case KVP_TYPE_GLIST:
    {
        slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue );
        kvp_value *pValue = NULL;
        gchar *key = get_key_from_path( pInfo->path );

        newInfo->context = LIST;

        slots_load_info( newInfo );
        pValue = kvp_value_new_glist_nc( newInfo->pList );
        kvp_frame_set_slot_nc(pInfo->pKvpFrame, key, pValue);
        g_string_free( newInfo->path, TRUE );
        g_slice_free( slot_info_t, newInfo );
        g_free( key );
        break;
    }
    case KVP_TYPE_FRAME:
    {
        slot_info_t *newInfo = slot_info_copy( pInfo, (GncGUID*)pValue ) ;
        KvpFrame *newFrame = kvp_frame_new();
        newInfo->pKvpFrame = newFrame;

        switch ( pInfo->context )
        {
        case LIST:
        {
            KvpValue *value = kvp_value_new_frame_nc( newFrame );
            gchar *key = get_key_from_path( pInfo->path );
            newInfo->path = g_string_assign( newInfo->path, key );
            pInfo->pList = g_list_append( pInfo->pList, value );
            g_free( key );
            break;
        }
        case FRAME:
        default:
        {
            gchar *key = get_key_from_path( pInfo->path );
            kvp_frame_set_frame_nc( pInfo->pKvpFrame, key, newFrame );
            g_free( key );
            break;
        }
        }

        newInfo->context = FRAME;
        slots_load_info ( newInfo );
        g_string_free( newInfo->path, TRUE );
        g_slice_free( slot_info_t, newInfo );
        break;
    }
    default:
        break;
    }
}