This is some code found on googling kprinter and cups. I don't know to which
version it applies, but this was in CVS at some time.

00608 bool CupsdConf::loadAvailableResources()
00609 {
00610     KConfig conf("kdeprintrc");
00611     conf.setGroup("CUPS");
00612     QString host = conf.readEntry("Host",cupsServer());
00613     int     port = conf.readNumEntry("Port",ippPort());
00614     http_t  *http_ = httpConnect(host.local8Bit(),port);
00615 
00616     resources_.clear();
00617     // standard resources
00618     resources_.append(new CupsResource("/"));
00619     resources_.append(new CupsResource("/admin"));
00620     resources_.append(new CupsResource("/printers"));
00621     resources_.append(new CupsResource("/classes"));
00622     resources_.append(new CupsResource("/jobs"));
00623 
00624     if (!http_)
00625         return false;
00626 
00627     // printer resources
00628     ipp_t   *request_ = ippNew();
00629     cups_lang_t*    lang = cupsLangDefault();
00630     ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang));
00631     ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language);
00632     request_->request.op.operation_id = CUPS_GET_PRINTERS;
00633     request_ = cupsDoRequest(http_, request_, "/printers/");
00634     if (request_)
00635     {
00636         QString name;
00637         int type(0);
00638         ipp_attribute_t *attr = request_->attrs;
00639         while (attr)
00640         {
00641             // check new printer (keep only local non-implicit printers)
00642             if (!attr->name)
00643             {
00644                 if (!(type & CUPS_PRINTER_REMOTE) && !(type & CUPS_PRINTER_IMPLICIT) && !name.isEmpty())
00645                     resources_.append(new CupsResource("/printers/"+name));
00646                 name = "";
00647                 type = 0;
00648             }
00649             else if (strcmp(attr->name, "printer-name") == 0) name = attr->values[0].string.text;
00650             else if (strcmp(attr->name, "printer-type") == 0) type = attr->values[0].integer;
00651             attr = attr->next;
00652         }
00653         if (!(type & CUPS_PRINTER_REMOTE) && !(type & CUPS_PRINTER_IMPLICIT) && !name.isEmpty())
00654             resources_.append(new CupsResource("/printers/"+name));
00655         ippDelete(request_);
00656     }
00657     // class resources
00658     request_ = ippNew();
00659     ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_CHARSET, "attributes-charset", NULL, cupsLangEncoding(lang));
00660     ippAddString(request_, IPP_TAG_OPERATION, IPP_TAG_LANGUAGE, "attributes-natural-language", NULL, lang->language);
00661     request_->request.op.operation_id = CUPS_GET_CLASSES;
00662     request_ = cupsDoRequest(http_, request_, "/classes/");
00663     if (request_)
00664     {
00665         QString name;
00666         int type(0);
00667         ipp_attribute_t *attr = request_->attrs;
00668         while (attr)
00669         {
00670             // check new class (keep only local classes)
00671             if (!attr->name)
00672             {
00673                 if (!(type & CUPS_PRINTER_REMOTE) && !name.isEmpty())
00674                     resources_.append(new CupsResource("/classes/"+name));
00675                 name = "";
00676                 type = 0;
00677             }
00678             else if (strcmp(attr->name, "printer-name") == 0) name = attr->values[0].string.text;
00679             else if (strcmp(attr->name, "printer-type") == 0) type = attr->values[0].integer;
00680             attr = attr->next;
00681         }
00682         if (!(type & CUPS_PRINTER_REMOTE) && !name.isEmpty())
00683             resources_.append(new CupsResource("/classes/"+name));
00684         ippDelete(request_);
00685     }
00686     httpClose(http_);
00687     return true;
00688 }
00689 