<commit_before>#include "e_mod_notifier_host_private.h"

#define WATCHER_BUS "org.kde.StatusNotifierWatcher"
#define WATCHER_PATH "/StatusNotifierWatcher"
#define WATCHER_IFACE "org.kde.StatusNotifierWatcher"

#define ITEM_IFACE "org.kde.StatusNotifierItem"

#define HOST_REGISTRER "/bla" //TODO check what watcher expect we send to him

#undef ERR
#define ERR(...) fprintf(stderr, __VA_ARGS__)

extern const char *Category_Names[];
extern const char *Status_Names[];

typedef struct _Notifier_Host_Data {
   Instance_Notifier_Host *host_inst;
   void *data;
} Notifier_Host_Data;

static Eina_Bool
service_string_parse(const char *item, const char **path, const char **bus_id)
{
   const char *p;

   p = strchr(item, '/');
   if (!p) return EINA_FALSE;
   *path = eina_stringshare_add(p);
   *bus_id = eina_stringshare_add_length(item, p - item);
   return EINA_TRUE;
}

static Notifier_Item *
notifier_item_find(const char *path, const char *bus_id, Context_Notifier_Host *ctx)
{
   Notifier_Item *item;
   EINA_INLIST_FOREACH(ctx->item_list, item)
     {
        if (item->bus_id == bus_id && item->path == path)
          return item;
     }
   return NULL;
}

static int
id_find(const char *s, const char *names[])
{
   unsigned i;

   for (i = 0; names[i]; i++)
     {
        if (!strcmp(s, names[i]))
          return i;
     }
   return 0;
}

static void
icon_pixmap_deserialize(Eldbus_Message_Iter *variant, uint32_t **data, int *w, int *h)
{
   Eldbus_Message_Iter *iter, *struc;
   int tmpw, tmph;

   *data = NULL;
   *w = *h = 0;
   eldbus_message_iter_arguments_get(variant, "a(iiay)", &iter);
   while (eldbus_message_iter_get_and_next(iter, 'r', &struc))
     {
        Eldbus_Message_Iter *imgdata;

        if (eldbus_message_iter_arguments_get(struc, "iiay", &tmpw, &tmph, &imgdata))
          {
             uint32_t *img;
             int len;

             //only take this img if it has a higher resolution
             if (tmpw > *w || tmph > *h)
               {
                  *w = tmpw;
                  *h = tmph;
                  if (eldbus_message_iter_fixed_array_get(imgdata, 'y', &img, &len))
                    {
                       unsigned int pos;

                       *data = malloc(len * sizeof(int));
                       for (pos = 0; pos < (unsigned int)len; pos++)
                         (*data)[pos] = eina_swap32(img[pos]);
                    }
               }
          }
     }<commit_msg>e systray/indicator protocol pixmap data fetch fix<commit_after>#include "e_mod_notifier_host_private.h"

#define WATCHER_BUS "org.kde.StatusNotifierWatcher"
#define WATCHER_PATH "/StatusNotifierWatcher"
#define WATCHER_IFACE "org.kde.StatusNotifierWatcher"

#define ITEM_IFACE "org.kde.StatusNotifierItem"

#define HOST_REGISTRER "/bla" //TODO check what watcher expect we send to him

#undef ERR
#define ERR(...) fprintf(stderr, __VA_ARGS__)

extern const char *Category_Names[];
extern const char *Status_Names[];

typedef struct _Notifier_Host_Data {
   Instance_Notifier_Host *host_inst;
   void *data;
} Notifier_Host_Data;

static Eina_Bool
service_string_parse(const char *item, const char **path, const char **bus_id)
{
   const char *p;

   p = strchr(item, '/');
   if (!p) return EINA_FALSE;
   *path = eina_stringshare_add(p);
   *bus_id = eina_stringshare_add_length(item, p - item);
   return EINA_TRUE;
}

static Notifier_Item *
notifier_item_find(const char *path, const char *bus_id, Context_Notifier_Host *ctx)
{
   Notifier_Item *item;
   EINA_INLIST_FOREACH(ctx->item_list, item)
     {
        if (item->bus_id == bus_id && item->path == path)
          return item;
     }
   return NULL;
}

static int
id_find(const char *s, const char *names[])
{
   unsigned i;

   for (i = 0; names[i]; i++)
     {
        if (!strcmp(s, names[i]))
          return i;
     }
   return 0;
}

static void
icon_pixmap_deserialize(Eldbus_Message_Iter *variant, uint32_t **data, int *w, int *h)
{
   Eldbus_Message_Iter *iter, *struc;
   int tmpw, tmph;

   *data = NULL;
   *w = *h = 0;
   eldbus_message_iter_arguments_get(variant, "a(iiay)", &iter);
   while (eldbus_message_iter_get_and_next(iter, 'r', &struc))
     {
        Eldbus_Message_Iter *imgdata;

        if (eldbus_message_iter_arguments_get(struc, "iiay", &tmpw, &tmph, &imgdata))
          {
             uint32_t *img;
             int len;

             //only take this img if it has a higher resolution
             if ((tmpw > *w) || (tmph > *h))
               {
                  if (eldbus_message_iter_fixed_array_get(imgdata, 'y', &img, &len))
                    {
                       unsigned int sz;

                       sz = tmpw * tmph;
                       if ((unsigned int)len == (sz * 4))
                         {
                            uint32_t *tmp;

                            tmp = malloc(tmpw * tmph * 4);
                            if (tmp)
                              {
                                 uint32_t *s, *d, *e;

                                 if (*data) free(*data);
                                 *data = tmp;
                                 *w = tmpw;
                                 *h = tmph;
                                 for (s = img, e = img + sz, d = *data;
                                      s < e; s++, d++)
#if (defined __BYTE_ORDER && __BYTE_ORDER == __LITTLE_ENDIAN) || (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
                                 *d = eina_swap32(*s);
#else
                                 *d = *s;
#endif
                              }
                         }
                    }
               }
          }
     }
{'fraction_non_alphanumeric': 0.11179904475499734, 'fraction_numerical': 0.004422430567840085, 'mean_word_length': 1.937142857142857, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4884020', 'n_tokens_mistral': 1925, 'n_tokens_neox': 1865, 'n_words': 444}