File indexing completed on 2024-11-24 04:42:06

0001 
0002 /*
0003     SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 package org.kde.kcalendarcore;
0008 
0009 import android.content.*;
0010 import android.database.*;
0011 import android.provider.*;
0012 
0013 public class CalendarPlugin
0014 {
0015     public CalendarPlugin(android.content.Context context)
0016     {
0017         m_context = context;
0018     }
0019 
0020     private static final String[] CALENDAR_PROJECTION = new String[] {
0021         CalendarContract.Calendars._ID,
0022         CalendarContract.Calendars.CALENDAR_DISPLAY_NAME,
0023         CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL,
0024         CalendarContract.Calendars.CALENDAR_COLOR,
0025         CalendarContract.Calendars.CALENDAR_TIME_ZONE,
0026         CalendarContract.Calendars.OWNER_ACCOUNT
0027     };
0028 
0029     public CalendarData[] getCalendars()
0030     {
0031         ContentResolver cr = m_context.getContentResolver();
0032         String calSelection = "(( " + CalendarContract.Calendars.VISIBLE + " == 1 ) AND ( "
0033             + CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL + " != " + CalendarContract.Calendars.CAL_ACCESS_NONE + " ))";
0034         Cursor cur = cr.query(CalendarContract.Calendars.CONTENT_URI, CALENDAR_PROJECTION, calSelection, null, null);
0035 
0036         CalendarData result[] = new CalendarData[cur.getCount()];
0037         while (cur.moveToNext()) {
0038             CalendarData data = new CalendarData();
0039             data.id = cur.getLong(0);
0040             data.displayName = cur.getString(1);
0041             data.accessLevel = cur.getInt(2);
0042             data.color = cur.getInt(3);
0043             data.timezone = cur.getString(4);
0044             data.owner = cur.getString(5);
0045             result[cur.getPosition()] = data;
0046         }
0047 
0048         return result;
0049     }
0050 
0051     private android.content.Context m_context;
0052 }